CodeIgniter Forums
Leanest way of going multilingual - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Leanest way of going multilingual (/thread-34743.html)



Leanest way of going multilingual - El Forum - 10-08-2010

[eluser]fauria81[/eluser]
Hi everybody!

Ive just started a new project using Codeigniter (i have done a couple more before), but this time i need to go multilingal (10 languages, including latin, cyrilic, arabic, chinese and japanese).

I would like to optimize the website for SEO, and regarding URL's, ive think on something like:

http://en.example.com/search/products/keyword: Search for products containing 'keyword' in English.
http://es.example.com/busqueda/productos/palabra: Search ('busqueda') for products ('productos') containing keyword ('palabra') in Spanish.

Basically i need both controllers class names and methods in several languages.

I think i can use
Code:
_remap()
on my controllers, and tweak
Code:
routes.php
to handle the first segment of the URL and force a language.

If http://www.example.com/whatever is used, i think i will determine the language via IP, and then redirect to http://xx.example.com, or fallback to English by default, but maybe another approach would be more desirable.

Any suggestions would be appreciated. Thank you very much!


Leanest way of going multilingual - El Forum - 10-08-2010

[eluser]n0xie[/eluser]
I found this to be the easiest to use when dealing with multiple languages: http://maestric.com/doc/php/codeigniter_i18n


Leanest way of going multilingual - El Forum - 10-09-2010

[eluser]fedeisas[/eluser]
[quote author="n0xie" date="1286548314"]I found this to be the easiest to use when dealing with multiple languages: http://maestric.com/doc/php/codeigniter_i18n[/quote]

I've also used this library and it rocks! Altough, you'll have to write some routes for your controllers. I mean:

$route['(:any)/busqueda/productos/(.+)$'] = "search/products/$1";
$route['(:any)/search/products/(.+)$'] = "search/products/$1";

To avoid doing this, some folks use some urls like this:
www.example.com/buscar/productos/computadores/sp-1
www.example.com/search/products/computers/sp-1

And the real WORKING part of the url, is the last segment. So, their controller get the last segment and SP-1 stands for Search Product with ID = 1.
This unorthodox method works right when you need multilingual URLs.

Although I'm not really sure how this pretty URLs impact on SEO rankings.

Good Luck