Getting current locale

Permalink Browser Info Environment
I saw that the current language for the active section can be retrieved using
$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
PatrickHeck
View Replies: View Best Answer
PatrickHeck replied on at Permalink Reply
PatrickHeck
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?
Mainio replied on at Permalink Best Answer Reply
Mainio
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
PatrickHeck replied on at Permalink Reply
PatrickHeck
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.
Mainio replied on at Permalink Reply
Mainio
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".
PatrickHeck replied on at Permalink Reply
PatrickHeck
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.

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.