21491 Posts in 5783 Topics by 2622 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 332 Views |
-
[SOLVED] How to add another cast to $Locale

27 February 2012 at 8:27pm
Hi!
As $Locale.Nice, I need another cast, $Locale.NiceShort
How to add another cast to $Locale for template?
Thanks.
Regards,
Jose A. -
Re: [SOLVED] How to add another cast to $Locale

29 February 2012 at 4:51am
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...
-
Re: [SOLVED] How to add another cast to $Locale

29 February 2012 at 6:11am
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.
| 332 Views | ||
|
Page:
1
|
Go to Top |

