You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
is it possible to fallback to another language than the default/master language (with $strict = false)?
Lets say i have 3 languages: german, english, russian.
Default language is german (most content ist german, client is german).
Now when some contents are translated to english (but not to russian), it would be nice to display english (more international) contents to russian visitors (instead of german though it's the master language).
The text was updated successfully, but these errors were encountered:
Currently, that's not possible. Ideally, your project-setup has the master-language as preferred fallback. Eg. English as master-language.
You could create a separate extension with that functionality though…
class FallbackTranslationExtension extends DataExtension
{
public function FT($fieldName)
{
$value = $this->owner->getLocalizedValue($fieldName, true);
if ($value) {
return $value;
}
// Using `en_US` as fallback locale here
$fallback = TranslatableDataObject::localized_field($fieldName, 'en_US');
return $this->owner->dbObject($fallback);
}
}
Then use $FT('MyField') in templates…
I'm not sure how common your use-case is… maybe it would be worthwhile to add the functionality to the module. Ideally, this would be configurable via config, so that you can specify a fallback order for every language? The problem I see with that, is that it's only applied to DataObjects and doesn't affect the translation of pages, which could be confusing.
Hi,
is it possible to fallback to another language than the default/master language (with $strict = false)?
Lets say i have 3 languages: german, english, russian.
Default language is german (most content ist german, client is german).
Now when some contents are translated to english (but not to russian), it would be nice to display english (more international) contents to russian visitors (instead of german though it's the master language).
The text was updated successfully, but these errors were encountered: