Merge pull request #133 from Ekman/master

Links in head will now include translated versions of each page including itself
This commit is contained in:
Ingo Schommer 2013-08-20 12:44:20 -07:00
commit b24316167a

View File

@ -1505,7 +1505,11 @@ class Translatable extends DataExtension implements PermissionProvider {
function MetaTags(&$tags) { function MetaTags(&$tags) {
$template = '<link rel="alternate" type="text/html" title="%s" hreflang="%s" href="%s" />' . "\n"; $template = '<link rel="alternate" type="text/html" title="%s" hreflang="%s" href="%s" />' . "\n";
$translations = $this->owner->getTranslations(); $translations = $this->owner->getTranslations();
if($translations) foreach($translations as $translation) { if($translations) {
$translations = $translations->toArray();
$translations[] = $this->owner;
foreach($translations as $translation) {
$tags .= sprintf($template, $tags .= sprintf($template,
Convert::raw2xml($translation->Title), Convert::raw2xml($translation->Title),
i18n::convert_rfc1766($translation->Locale), i18n::convert_rfc1766($translation->Locale),
@ -1513,6 +1517,7 @@ class Translatable extends DataExtension implements PermissionProvider {
); );
} }
} }
}
function providePermissions() { function providePermissions() {
if(!SiteTree::has_extension('Translatable') || !class_exists('SiteTree')) return false; if(!SiteTree::has_extension('Translatable') || !class_exists('SiteTree')) return false;