MetaTags now includes translated versions of itself including the default translation

This commit is contained in:
Niklas Ekman 2013-08-18 18:41:08 +02:00
parent 34a171b9dc
commit 03722d2a8e

View File

@ -1467,7 +1467,14 @@ 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) {
$tags .= sprintf($template,
Convert::raw2xml($this->owner->Title),
i18n::convert_rfc1766($this->owner->Locale),
$this->owner->AbsoluteLink()
);
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),
@ -1475,6 +1482,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;