[Internationalization] - on tools folder/files
Permalink Browser Info Environment
Hello, I m currently sending mail via an ajax script call on the tool folder.
But the T() function seems to not translate any of my sentence.
This is what I have in my code
The get Locale is returning the good language, the echo always return 'trans : hello word'
Thank you
But the T() function seems to not translate any of my sentence.
This is what I have in my code
$c = Page::getByID($_REQUEST['cId']); Loader::model('section', 'multilingual'); $lang = strtolower(MultilingualSection::getCurrentSection()->getLocale()); echo t('trans : hello word');
The get Locale is returning the good language, the echo always return 'trans : hello word'
Thank you
Type: | Discussion |
---|---|
Status: | New |
Hello Mkly,
Thanks for your response, nevertheless it's not working still the same ('trans : hello world'). It's of course in my PO file (the string is translate on a page juste before so I m sure it's working).
It's so weird, I went deeper, and on localizaion library I have :
($zt in my case is not an object...) so it's returning the text itself.. still does not know why.
Best Regards
Thanks for your response, nevertheless it's not working still the same ('trans : hello world'). It's of course in my PO file (the string is translate on a page juste before so I m sure it's working).
It's so weird, I went deeper, and on localizaion library I have :
function t($text) { $zt = Localization::getTranslate(); if (func_num_args() == 1) { if (is_object($zt)) { return $zt->_($text); } else { return $text; } }
($zt in my case is not an object...) so it's returning the text itself.. still does not know why.
Best Regards
Hello,
setLocale() is not a static method, so you might want to try this. I just tested this on my concrete5.6.1.2 development environment.
With the po file I downloaded from Transifex it displayed
Avbryt
I would make sure that the language pack is installed. Can you select Swedish in the Dashboard for the sites default language? You wouldn't need to do this for what we are doing, but it would confirm that the language pack is installed correctly and the site is finding it.
Best Wishes,
Mike
setLocale() is not a static method, so you might want to try this. I just tested this on my concrete5.6.1.2 development environment.
$loc = Localization::getInstance(); $loc->setLocale('sv_SE'); echo t('Cancel');
With the po file I downloaded from Transifex it displayed
Avbryt
I would make sure that the language pack is installed. Can you select Swedish in the Dashboard for the sites default language? You wouldn't need to do this for what we are doing, but it would confirm that the language pack is installed correctly and the site is finding it.
Best Wishes,
Mike
Great thanks, It's working properly. as you said wrong call on getInstance() :-)
Best Regards
Xavier
Best Regards
Xavier
Indeed. Oops. Glad it's working for you now.
Best Wishes,
Mike
Best Wishes,
Mike
I do not know why but this is not working for me. For one of the blocks I created I make an ajax call to a script in the tools folder and I am trying to get it to recognize the language or force it and nothing seems to work.
Just echos "Model" onto the page. If anyone has any ideas please help. I am debugging it right now to try and trace it down.
$loc = Localization::getInstance(); $loc->setLocale('pt_BR'); echo t('Model');
Just echos "Model" onto the page. If anyone has any ideas please help. I am debugging it right now to try and trace it down.
Is the pt_BR language installed into your site?
Best Wishes,
Mike
Best Wishes,
Mike
Yes. Through the multilingual and multilingual plus add-ons we have setup multiple languages. Everything gets translated every where that is wrapped in a t function except for any ajax calls to tools. None of their strings wrapped in t functions get translated. When the tools scripts are called they dont know what language is being used and I cannot seem to force it with the code I posted above.
If you create a tools file with this,
What do you get?
Best Wishes,
Mike
$loc = Localization::getInstance(); var_dump($loc->getLocale());
What do you get?
Best Wishes,
Mike
string(5) "en_US"
So I finally figured it out. Thanks for your help. I had an override of localization.php. This override was removed though and I cleared the cache but it was still looking for the override for some reason. As soon as I copied the one out of the concrete directory and put it in the right doc root folder it started working. I have to figure out why the override did not clear but at least I its working.
Good to hear.
Best Wishes,
Mike
Best Wishes,
Mike
That said, do you have 'trans: hello world' in your po file?
Best Wishes,
Mike