Getting current locale
Permalink Browser Info Environment
I saw that the current language for the active section can be retrieved using
Now I am wondering if there is also a way to get the current locale. e.g. for date formatting.
$lh = Loader::helper('section', 'multilingual'); print $lh->getLanguage();
Now I am wondering if there is also a way to get the current locale. e.g. for date formatting.
Type: | Discussion |
---|---|
Status: | New |
A follow up to my own post that is connected to the initial question: How has the t function to be modified to use the language of the currently active tree? As I have seen, it reads the LOCALE constant to determin the target language. So is there a way to intercept this without complex changes in the core?
Hi PatrickHeck,
The functionality you're looking for (so that the t-function will consider under which language you currently are) is available in the Language Manager add-on:
http://www.concrete5.org/marketplace/addons/language-manager/...
Check out the introductory video, this issue is demonstrated at 6:45->
With the Language Manager installed, you will also have a global variable named $langPage that contains the currently active language section (the add-on will use the MultilingualSection object available from the Internationalization add-on).
Br,
Antti / Mainio
The functionality you're looking for (so that the t-function will consider under which language you currently are) is available in the Language Manager add-on:
http://www.concrete5.org/marketplace/addons/language-manager/...
Check out the introductory video, this issue is demonstrated at 6:45->
With the Language Manager installed, you will also have a global variable named $langPage that contains the currently active language section (the add-on will use the MultilingualSection object available from the Internationalization add-on).
Br,
Antti / Mainio
Thanks mainio, this is exactly what I was looking for.
Still, I think it would be great if this was part of the core or the internationalization add-on since the multilingual functionality is not really complete without it.
Still, I think it would be great if this was part of the core or the internationalization add-on since the multilingual functionality is not really complete without it.
Yeah, it would be good, but these both are quite new add-ons and I also feel that there are things to learn from each other.
One thing also I forgot to mention, the whole current locale is also available once you install the Language Manager in $GLOBALS['LOCALE']. This means that instead of "en" you would get e.g. "en_US".
One thing also I forgot to mention, the whole current locale is also available once you install the Language Manager in $GLOBALS['LOCALE']. This means that instead of "en" you would get e.g. "en_US".
I figured out that beside the great "Language Manager" add-on there is another way to get the current locale quite easily.http://www.concrete5.org/marketplace/addons/internationalization/fo...
This still leaves the t() function problem unresolved though.
This still leaves the t() function problem unresolved though.