Welcome Guest, Not a member yet? Register   Sign In
2 Languages on my site: how to start ?
#31

[eluser]yannyannyann[/eluser]
Ok done !

Many many thanks you guys helped me out Smile
#32

[eluser]yannyannyann[/eluser]
For the language file. I plan to do this :

- a php file in the folder language/french/fr.php
- a php file in the folder language/english/en.php

In each of these files an array like this :
Code:
// Example of the french array
$lang_template = array(
'photos' => 'photos',
'videos' => 'vidéos',
'last collection' => 'dernière collection',
...
)


Then depending on current_language(), I will read fr.php or en.php


Does this solution sound right to you ?
Is it ok from a MVC point of view ? (stupide question maybe)
#33

[eluser]TheFuzzy0ne[/eluser]
You could do that, but CodeIgniter provides you with the functionality to do this anyway. You would create a language file using $lang as the array name, not $lang_template, and then define your translations as you have above. Then you'd set the language (according to the short language code from the URL), load the file by name (i.e photos, or homepage etc...) and CodeIgniter will load the right file for you, so it's then just a case of using lang() from the language helper to get your code.
#34

[eluser]yannyannyann[/eluser]
Any idea why when I do :

Code:
$this->lang->load('all', current_language());

it prints the content of the array (like a print_r) ?
#35

[eluser]TheFuzzy0ne[/eluser]
Probably because you're missing the starting dollar sign for the array variable, or something along those lines. If you can't figure it out, please post the contents of your lang file.
#36

[eluser]yannyannyann[/eluser]
I am very stupid please forgive me Smile Smile Smile Smile
forgot to add the php tags !
#37

[eluser]TheFuzzy0ne[/eluser]
Hehe! Easy mistake to make. The give away is when you're using an editor that supports syntax highlighting. If your code is not highlighted as it should be, that's usually the problem. Smile




Theme © iAndrew 2016 - Forum software by © MyBB