Hi!
As $Locale.Nice, I need another cast, $Locale.NiceShort
How to add another cast to $Locale for template?
Thanks.
Regards,
Jose A.
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hi!
As $Locale.Nice, I need another cast, $Locale.NiceShort
How to add another cast to $Locale for template?
Thanks.
Regards,
Jose A.
I don't think you can easily extend DBLocale for this, since it is used by Translatable directly. .So maybe the easiest way is to create a function in the page controler, that manipulates the locale? Then call that from the template...
Hi martimiz!
I've been able to find the solution.
SilverStripe is wonderful. It's a pity that he lacks a better documentation.
I put it here in case someone needs it.
class DBLocaleExtension extends Extension {
function NiceShort() {
return i18n::get_language_name(i18n::get_lang_from_locale($this->owner->value));
}
}
In _config.php:
Object::add_extension('DBLocale', 'DBLocaleExtension');
Regards,
Jose A.