cms icon indicating copy to clipboard operation
cms copied to clipboard

Force language on foreign environment

Open Opariti opened this issue 11 years ago • 10 comments

I have a site in French, just by creating the application/i18n/fr.php translation file. The whole site, loaded on a hosted server, shows-up in French as soon as I'm using OS/keyboard in French. If I access the site from a en_US OS (Windows 7, Chrome)/keyboard, the translation is not performed. How can I force the use of French from the en_US (or any non-French) computer? Thx

Opariti avatar Nov 15 '13 19:11 Opariti

Please change default language in bootstrap.php and config/site.php. I think it'll be sufficient. 'locale' => 'en_US'

sandeepone avatar Nov 15 '13 19:11 sandeepone

  1. Disable in bootstrap.php autolocale
Kohana::init(array(
    'autolocale' => FALSE
));
  1. Force language in bootstrap.php
I18n::$lang = 'en';
  1. Delete cookies

sergeyklay avatar Nov 15 '13 19:11 sergeyklay

@sandeepone Not needed to modify config file

sergeyklay avatar Nov 15 '13 19:11 sergeyklay

@sergeyklay Perhaps we're not using this methods i just noticed. I prefer simple syntax & lightweight: https://github.com/gleez/cms/blob/master/modules/gleez/classes/i18n.php#L44

sandeepone avatar Nov 15 '13 19:11 sandeepone

@sandeepone Hence we have 2 methods to solve this issue :)

sergeyklay avatar Nov 15 '13 19:11 sergeyklay

@sergeyklay if Kohana::$autolocale is FALSE it defaults to english https://github.com/gleez/cms/blob/master/modules/gleez/classes/gleez.php#L117

sandeepone avatar Nov 15 '13 19:11 sandeepone

Yes, but I18n::$lang = '...'; should sets needed value

sergeyklay avatar Nov 15 '13 20:11 sergeyklay

Sergey is right. This should be added in bootstrap.php; example for French:

/**

  • Impose fr_FR whatever the client configuration */ Kohana::init(array( 'autolocale' => FALSE )); I18n::$lang = 'fr';

Thank you guys, I have all your answers stored in my email box, but, again, I think that all these should be referenced somewhere in the wiki or FAQ so that others can better use your nice work.

Opariti avatar Nov 15 '13 20:11 Opariti

@Opariti Thank you. We're working on bootstrap 3.x version, once we're done, we'll be adding all this info in wiki. It would be more helpful if you could share your french locale, we can add with rest of the locales.

@sergeyklay i know i18n::$lan= '...' sets, but we still need to make it more mature. https://github.com/gleez/cms/blob/master/modules/gleez/classes/i18n.php#L76 If i get some time over this weekend, i'll psuh commits

I'll keep this issue open until we cleanup the code and make it more mature.

sandeepone avatar Nov 15 '13 20:11 sandeepone

@sandeepone Let's quickly go to BS3 :)

sergeyklay avatar Nov 15 '13 20:11 sergeyklay