hiii, i m trying to set my appliocation in multiple language ("frensh ","arabic"), and i try to create a file that's makes the corerspondance bettwen languages. example:
file for frensh language:
<?
'1' => 'identifiant',
?>
file for arabic language :
<?
'1' => 'دخول',
?>
please i'v consult the docummentation but i when i load my file language and i try to use attribute of the files it's dose not work.
Language strings, like config data, are loaded into a multidimensional array, the level being determined by the specified "group" you load the language file in. If you don't specify a "group", the language file will be loaded in the "root" of the array.
So, if you do: Lang::load('myfile'); you use Lang::get("1"). If you do Lang::load('myfile', 'mygroup'); you use Lang::get("mygroup.1").
This way of accessing array's is what we call "dot-notation", you'll find this in lots of places in the documentation, and uses the Arr class to access arrays.
So Arr::get($array, "this.that") is the same as $array["this"]["that"].
Which language is loaded depends on the settings in your application config file. If you want to change the language, make sure you do that before a Request is executed (which happens in your index.php), because the language is cached per request. Changing it in a controller will cause all views to be generated in the wrong language.
So you advise me not to change the language of the application at the controller it's would be a good ideato modifiy the langage at the file (template.php) ???
You can change the language in the controller, but you have to do it before you create views (or the template in case of Controller_Template). Which means in the before(), and before you call parent::before().
The reason for this is that FuelPHP uses "lazy rendering" for views, views are only rendered when needed, which in most cases is long after the request has been processed. To make sure the View still knows in what language it must be rendered, it picks up the current language when the View object is instantiated, saves it internally, and uses that to render the view.
So changing the language after the View object has been created doesn't change the language in that View.