mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
Allow templates easy access to the language of the current content.
This commit is contained in:
parent
1bb392c8dc
commit
8ec76b063c
@ -1108,6 +1108,17 @@ class Translatable extends DataExtension implements PermissionProvider {
|
|||||||
return $table;
|
return $table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide templates with an easy way to display the languate of the content being viewed, in both native language
|
||||||
|
* and english.
|
||||||
|
*
|
||||||
|
* @param boolean $native [true] Outputs the language name in its own language if true, english string if false.
|
||||||
|
* @return string The name of the content language.
|
||||||
|
*/
|
||||||
|
public function getContentLanguage($native = true) {
|
||||||
|
return i18n::get_language_name(i18n::get_lang_from_locale(i18n::convert_rfc1766($this->owner->Locale)),$native);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all related translations for the current object,
|
* Gets all related translations for the current object,
|
||||||
* excluding itself. See {@link getTranslation()} to retrieve
|
* excluding itself. See {@link getTranslation()} to retrieve
|
||||||
|
Loading…
Reference in New Issue
Block a user