10928 Posts in 2612 Topics by 1809 members
|Go to End|
19 April 2014 at 11:34am Last edited: 19 April 2014 11:35am
I'm a bit amazed I don't manage to get this to work, but well.
I already have my website translated into Spanish (from English). I'm using the Translatable module for that, works great. es_ES is in Translatable's allowed_locales.
For some specific custom templates, I'm using the _t construct, had the en.yml created for mysite, and then copied that file to es.yml. I changed the first line to read es:, and made the required translations.
I can't seem to figure out how to get the es.yml file to actually load though. It keeps using the value from en.yml (which I changed from the _t() construct, to make sure it actually does read from a language file).
es.yml is of course in the same folder as en.yml. It's the exact same file format with no syntax errors (as far as I can see). The file is also readable etc. I tried renaming it to es_ES.yml, as well as changing that first line to es_ES:. I tried adding es or es_ES to i18n:common_locales in config.yml. I tried removing any non-ansi characters. I did dev/build/, flush=1 and flush=all. Of course, I'm logged in as Administrator, and I uncached the template.
I do see any changes that I make in en.yml, but not those in es.yml, even though I'm on a Spanish page.
I simply don't know what else to try... how to make it load that es.yml file on pages that are Spanish?
19 April 2014 at 10:49pm
Make sure to do a ?flush=all...
20 April 2014 at 1:39am
Thanks for the suggestion. I have been doing that a lot though!
I found what's missing: despite being on a Spanish page (as determined by the Translatable module), SilverStripe does not believe it needs to choose the Spanish language files for the modules. In other words, Translatable's current_language is not synchronized with i18n's current_language.
Perhaps it's a config thing? I currently have in _config.php:
Translatable::set_allowed_locales(array( // available locales
And nothing about i18n, since en_US as default is fine, and I can't see any method to set available locales for i18n. I don't have any other locale/language settings anywhere else.
I can get it to work by putting the following in Page.php's init():
It just seems strange that I need to do this. Did I miss a setting somewhere, or is this simply the way?
20 April 2014 at 4:10am Last edited: 20 April 2014 4:11am
Well, guess I can answer that myself... yes, i18n's locale needs to be set explicitly, based on Translatable's.
|Go to Top|