![]() |
Multilanguge site - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Multilanguge site (/showthread.php?tid=13966) Pages:
1
2
|
Multilanguge site - El Forum - 12-13-2008 [eluser]sojic[/eluser] There is a lot of multilanguage threads, but I did not find proper thread to post there. Sorry again, but.... I developing multilanguage site. I extend controller with i18n (http://codeigniter.com/wiki/Category:Internationalization::Internationalization_Views_i18n/). I user also dx_auth library (form_validator....). Dx_auth messages are in application/language/english/dx_auth_lang.php. I make new folder in application/language/macedonian/, copy dx_auth_lang.php, translate it... but how to load this file? Also.... I want to create my own language file (for my application some standard sentences)... How to "handle" with this files? I have read http://ellislab.com/codeigniter/user-guide/libraries/language.html but it did not help me. Multilanguge site - El Forum - 12-14-2008 [eluser]sojic[/eluser] Anybody to help? Multilanguge site - El Forum - 12-14-2008 [eluser]jaswinder_rana[/eluser] I am new to this, so I'll share what I understand. Languages files are - System/language/{LANGUAGE} (english, german etc.) - System/application/language/{LANGUAGE} DX_Auth is at System/application/language/dx_auth_lang.php YOUR file will go at System/application/language/{YOUR FILE}_lang.php (Notice that _lang.php MUST be there. Then in your controller you can specify $this->load->language('{YOUR FILE}') (WITHOUT _lang.php) IF your language will be for WHOLE application and you ALWAYS want to load it then put it in application/config/autoload.php like $autoload['language'] = array('{YOUR_FILE}'); Try to make your language keys unique like in application/language/english/{YOUR_FILE}_lang.php $lang{'MY_something1'} = 'Something 1'; $lang{'MY_something2'} = 'Something 2'; Note the use of MY_ I am assuming (not really sure) that if you don't have it unique then it may overwrite some other language key which may already have been defined. Now, you can use it like $this->lang->line('MY_something1'); Hope this helps EDIT: There maybe some syntax errors as I just wrote this off the top of my head. So, I might be wrong with some object names but the way it works is right (I think) Multilanguge site - El Forum - 12-18-2008 [eluser]sojic[/eluser] Unable to load the requested language file: language/mk_lang.php The file is in system/language and in system/application/language Multilanguge site - El Forum - 12-18-2008 [eluser]jaswinder_rana[/eluser] File has to be in system/language/english/mk_lang.php OR (preffered for personal files) system/application/language/english/mk_lang.php I think you are missing one folder (or maybe posted it wrong) Multilanguge site - El Forum - 12-18-2008 [eluser]sojic[/eluser] Is it possible to organize language files like this: /system/application/languages/ english/contact_lang.php english/about_lang.php macedonian/contact_lang.php macedonian/about_lang.php Multilanguge site - El Forum - 12-18-2008 [eluser]jaswinder_rana[/eluser] Sure. In this case "macedomain" will be treated as different language. You can provide a way for users to change language. Default language can be changed in system/application/config/config.php with $config['language'] = "english"; Multilanguge site - El Forum - 12-18-2008 [eluser]sojic[/eluser] How to change config language from code in controller? I user i18n as controller for controllers. Multilanguge site - El Forum - 12-18-2008 [eluser]jaswinder_rana[/eluser] http://ellislab.com/codeigniter/user-guide/libraries/language.html Multilanguge site - El Forum - 12-18-2008 [eluser]bgougent[/eluser] I remember having some problems when the language was defined in the config.php My solutions was to set the language in the session. If the entry was not created, my default language was english. Otherwise I loaded the language from the session. Place to load the language was in the contsructor. |