Welcome Guest, Not a member yet? Register   Sign In
Language selection problem
#5

[eluser]tomcode[/eluser]
I use
Code:
$this->config->set_item('language', $my_language);

to set the app's language before loading any language files.

I usually set it in MY_Controller, a hook would do the job, too.


A solution for international sites used to be : I18n on the Wiki
Personally I use a solution very close to i18n, I do not override the helper functions and have some other tweaks


Watch out when loading files using
Code:
$this->load->lang('filename', $language);
A file is only loaded once, trying to load it (edit) later one more time (/edit) in another language will fail.


For complex projects with loads of entries :

- I organise my language idents like URI's, using a point as segment separator

- I use conventions like adding _fmt to an ident when it used with sprintf()

- I override CI's lang->line() method to have it return the identifier when the entry is not found, very nice for debugging and allows to worry for translations later :
Code:
/**
* Fetch a single line of text from the language array
*
* return the passed ident if no entry is found
*
* @access    public
* @param    string    $ident     the language line ident
* @return    string
*/
function line($ident = '')
{
    $line = ($ident === '' OR ! isset($this->language[$ident])) ? $ident : $this->language[$ident];

    return $line;
}


Messages In This Thread
Language selection problem - by El Forum - 12-17-2010, 10:08 AM
Language selection problem - by El Forum - 12-17-2010, 10:22 AM
Language selection problem - by El Forum - 12-17-2010, 11:03 AM
Language selection problem - by El Forum - 12-18-2010, 01:41 AM
Language selection problem - by El Forum - 12-18-2010, 08:10 AM
Language selection problem - by El Forum - 12-20-2010, 02:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB