Welcome Guest, Not a member yet? Register   Sign In
il8n-aware uri class
#1

[eluser]romero619[/eluser]
Hi,
I need help/advice figuring out how to best customize the uri class so that it is 'il8n-aware'...
basically, I want the uri class to automatically handle lang codes in the uri string...

here are some basic requirements that Im guessing would work for my proposed solution:
1) be able enable/disable the auto-il8n functionality through the config file
Code:
$config['il8n']=TRUE|FALSE;
- false being the default

2) be able to setup a default lang code
Code:
$config['lang_default']='en';

3) be able to setup the allowed/supported lang codes in the config file
Code:
$config['langs']=array('en','es','fr','de');
- all other lang codes are ignored & default lang code is applied

4) uri class must auto-detect the lang code in the first (or second) uri segment (depending on whether or not uri rewriting is used)
and, if appropriate, update the global language variable $this->config->item['lang']

5) all uri class member functions should transparently & correctly be able to parse & handle the url string, taking into account the presence (or absence) of the lang code:
example:
uri #1
Code:
http://example.com/index.php/news/local/metro/crime_is_up
uri #2
Code:
http://example.com/index.php/en/news/local/metro/crime_is_up

if il8n is enabled ('$config['il8n']=TRUE),
then"$this->uri->segment(3)" should equal 'metro' for both uri strings #1 and #2.

if il8n is disabled ('$config['il8n']=FALSE),
then"$this->uri->segment(3)" should equal 'metro' for uri string #1,but it should equal 'local' for uri string #2
(this allows for default handling of uri strings)

6) the presence (or absence) of the lang codes should NOT affect routing;
i.e., duplicate routes should not be required in order to handle lang codes.
a route such as
Code:
$route['[a-z]+']
should ignore the lang code if il8n has been enabled

Ive looked at some of the other suggested il8n solutions using CI, but all of them seem too complex and/or intrusive, involving changes to many files, dependence on muliple views, etc..

I simply want the lang code extracted & handled as early & as discretely as possible, allowing me to later decide how to switch my content's language based on the current value of $this->config->item['lang'].

basically, I need some feedback on this solution.
And, also, some guidance on how & where in the uri.php code to best implement the necessary changes...

Better yet, if someone has already used this type of solution, Id appreciate it if you'd be willing to share your code...

cheers,
#2

[eluser]eoinmcg[/eluser]
have you tried this?
http://codeigniter.com/wiki/URI_Language_Identifier
#3

[eluser]umefarooq[/eluser]
try this also
http://maestric.com/doc/php/codeigniter_i18n




Theme © iAndrew 2016 - Forum software by © MyBB