CodeIgniter Forums
Internationalization in CI - any good examples? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Internationalization in CI - any good examples? (/thread-32664.html)



Internationalization in CI - any good examples? - El Forum - 07-30-2010

[eluser]Ki[/eluser]
Does anybody have good examples of internationalizing the site built on CI?
I am trying to build a complex solution where a site can reflect language, country, city selection independent of each other. For example, someone wants to see products located in New York but wants to choose spanish as prefered language.

The difficulty I am having is to make this work independent of each other. I am trying to avoid passing this through the URI, because then, every link on every page needs to be re-done to pass these settings on to the next page. I am leaning towards using sub domains... but how can I distinguish country, city and language within a subdomain?
Example (may not be good, but it shows the concept):

http://example.com/products/ - all products, site language english
http://fr.example.com/products/ - all products, site language french
http://fr.ca.example.com/products/ - all products in Canada, site language french
http://es.new_york.usa.example.com/products/ - all products in New York, USA, site language spanish

The catch with this method is there is no set pattern, such as lang.city.country.example.com so a situation like es.example.com may lead to either showing all products with site language being Spanish, or showing all products for spain with site default language being english.

Anyone has better ideas or knows of a "proper" way to do it in CI?

UPDATE
I have looked at the i18n wiki extension for CI, but it focuses on loading language specific views. I am not excited about creating multiple version of same view, particularly when all my views are just html code. I store actual text you see on the page in lang array. So what I would need is to load a specific lang file once language is identified. I am leaning toward http://city.country.example.com/lang/controller/method solution, but the .../lang/controller/... part worries me since for some controllers I have routes that pass everything after /controller/ as variables in no particular order. Then I catch them using uri_helper returning array($var1=>$value).

And there is still the issue of writing /lang/ into all consecutive urls throughout the whole site