Welcome Guest, Not a member yet? Register   Sign In
list all available languages for the site
#1

[eluser]chejnik[/eluser]
Hello, can someone give me a small hint how can I detect all language translations I store in my application/language directory? I would use it then in a list for user to choose.
Thanks in advance Ales
#2

[eluser]xwero[/eluser]
I think it's a bit tricky that way because you can add languages where the sentences in the files aren't translated yet.

After saying that you can get the directories easy with the directory helper
Code:
$languages = array_keys(directory_map('./system/application/languages/', TRUE));
Using the directory_map function you retrieve directories names as keys. The TRUE boolean states you only want the toplevel directory mapped.
#3

[eluser]chejnik[/eluser]
Hello, quite interesting.

I have found directory_helper and placed it to application/helper directory and load it in controller
Code:
$this->load->helper('directory_helper');
$data["languages"] = directory_map('./system/application/languages/', TRUE);

when I print_r - it shows only #
What do you think it the problem.
Thank you Ales
#4

[eluser]xwero[/eluser]
try with a full path to see what result that gives.
#5

[eluser]chejnik[/eluser]
Hello, it is solved.

Firstly I have found directory_helper in system/helpers directory, so no need for me to copy the text from browser and save it with many # inside it. My bad. Smile

And I blindly copy your advice
Code:
$data["languages"] = directory_map('./system/application/languages/', TRUE);
thought the directory is ./system/application/language/ .. single language Smile

Because there are suppressed warnings if ($fp = @opendir($source_dir)) I didnot see the mistake.

Thank you. Great. With regards Ales




Theme © iAndrew 2016 - Forum software by © MyBB