Apologies is this is one of those elementary sort of questions. Well I've spent a couple of hours searching for the last piece of what I need for my project to work, but I just like every other topic I search for about Magento, can't find that last bit of magic information that makes everything work.
In short, I inherited a project for which I wouldn't pick Magento to be the framework, and I'm basically stuck with Magento as too much work has already been done. There are pieces of native Magento that are used, but there is a great deal of coding completed in custom classes and custom tables. The app as a whole is behind a login screen and has no public areas.
The client is fairly happy with the way things are working so we just can't up and redevelop the thing.
My challenge at this point is to get the translation parts working. When a user logs in, the app needs to translate the site into the language according to custom options set in the user's profile. I need to do this with code. There is no dropdown or link to click on to switch between languages.
This is not a typical ecommerce website, but a custom B2B where the clientele is in Europe. The site needs to translate, at this moment, into four other languages other than English.
Poking around the interwebs I gathered this much:
i. I need a csv for my stuff at
-- added the file, entered a test case:
"New Order","Neue Ordnung"
ii. Updated the
config.xml with this:
<frontend> <translate> <modules> <xxxx_ssss> <files> <default>xxxx_ssss.csv</default> </files> </xxxx_ssss> </modules> </translate> </frontend>
iii. Enclosed the text to be test translated with the $this->__() function.
-- this is works. I see
"Neue Ordung" where I expect to see it, instead of the
This is all good and well, however, taking it one step further, things don't work. I need to set the language, via code, according to the user's profile.
I found a bit of code I've only seen once:
This seems to be able to "force" Magento to use that locale.
I added a test file at
app\locale\nl_NL\xxxx_ssss.csv with a different translation to see if Magento picks it up.
It doesn't. I still see my test translation from above.
If I print out
Mage::app()->getLocale() we can see (below) that the localCode has been set to
( [_defaultLocale:protected] => en_US [_locale:protected] => [_localeCode:protected] => nl_NL [_emulatedLocales:protected] => Array ( ) )
I also added another store view with the locale default language, for this test, to Dutch.
This still doesn't seem to work. I cleared out the cache (even though it's turned off, it's in development).
I just don't know what else I need to do to get this to work. (I'm basically "desperate" as I've clicked to the second and third pages of a Google search ;) )