CodeIgniter Forums
Add URI Language Identifier to core? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: Add URI Language Identifier to core? (/showthread.php?tid=61395)

Pages: 1 2 3 4


Add URI Language Identifier to core? - kennytang.hk - 04-12-2015

(I just start using CI for a few weeks and I like it. Hope it's not a stupid question/request.)

Although there are a solution on the Github wiki (https://github.com/bcit-ci/CodeIgniter/wiki/URI-Language-Identifier), I think it should be in the core for nicer localization and SEO.

How you guys think?


RE: Add URI Language Identifier to core? - ciadmin - 04-12-2015

What exactly are you proposing? "URI language identifier in core" is too vague.
The article you reference seems to suggest changing the routing (which would not work for everyone) and enhancing the Lang class.

Are you suggesting that something like this be built in so that all CI sites should do this?


RE: Add URI Language Identifier to core? - kennytang.hk - 04-12-2015

The purpose is to make URL like http://www.apple.com/ (English), http://www.apple.com/fr (French), http://www.apple.com/hk (Hong Kong). This is one of the best way for handling multilingual website I think.
I didn't mean to force everyone who making multilingual site to follow this. Using cookie or query string are good way too but I personally think that these are not elegant enough. It will be nice if CI provide us with this choice and make this as a build in solution.


RE: Add URI Language Identifier to core? - RWCH - 04-12-2015

I prefer the usual url layout example.com/class/function/ID (where class is the controller) and work with resource files.
So no need for a 'language segment'.

I am curious what others think. What are the advantages of this approach?


RE: Add URI Language Identifier to core? - ivantcholakov - 04-12-2015

I read the Wiki material in the past, but I didn't like it. I've got another implementation for CI3.

http://iridadesign.com/starter-public-edition-4/www/ - The default language English. There is an option for hiding the language segment for the default language, you can use it especially if the site supports only one language.
http://iridadesign.com/starter-public-edition-4/www/en/ - English again.
http://iridadesign.com/starter-public-edition-4/www/bg/ - Bulgarian
http://iridadesign.com/starter-public-edition-4/www/fr/ - French
http://iridadesign.com/starter-public-edition-4/www/pl/ - Polish
etc ...

A key precondition: The language segment is transparent for the routing system. Once it has been read it disappears from the internal array(s) that contain URI segments. Don't patch the routes.php configuration file about language support.


RE: Add URI Language Identifier to core? - sv3tli0 - 04-12-2015

1 SEO tip
if
/ - is english
/en must not exists - else you will have duplicate content (you can handle this case with canonicals but its not a good option..)

For the thread - yes there is a need of supporting locale inside the router by default.
There is always locale - 1 default or many it doesn't matter. Even if its not displayed (if its 1 only) you again have language which you will output.
So CI must provide fast and easy way to catch and handle language/locale by its routers..


RE: Add URI Language Identifier to core? - ivantcholakov - 04-13-2015

@sv3tli0

I generate the links according to your recommendation. "Hidden" routes are not good indeed, duplicates that I am causing could be blocked easily, I suppose.

Speaking of SEO...
http://iridadesign.com/starter-public-edition-4/www/sitemap.xml - the root entry.
http://iridadesign.com/starter-public-edition-4/www/welcome/sitemap/xml - an entry specific to a particular module, this one declares language translations.


Edit 13-APR-2015:
@sv3tli0
Thank you very much! I have just put 301 redirections for solving the duplicate content problem.


RE: Add URI Language Identifier to core? - mwhitney - 04-13-2015

For SEO with duplicate content, don't redirect, use canonical URLs:
http://moz.com/learn/seo/canonicalization


RE: Add URI Language Identifier to core? - ivantcholakov - 04-13-2015

From what I've read, both of canonical URLs and 301 redirects are possible methods, I hesitate. Now I did redirection, code for this is within the router and it is dirty, because there is no controller instance created, I don't like it.

Maybe canonicalization would be better, and for making it easy, base controller (for example) should propose a default method for generation of canonical URL. TODO.

Edit: I got in favor for canonicalization, because it would deal with more duplicates:
http://site.com/
http://site.com/index.php
http://site.com/welcome
http://site.com/welcome/
http://site.com/welcome/index
http://site.com/welcome/index/


RE: Add URI Language Identifier to core? - PaulD - 04-20-2015

I voted No, because I do not want the framework to dictate how I choose to handle multi-language implementations.

It depends so much on the site itself, that I have used several approaches in the past with CI, all of them easy enough to implement.

There is no clear or set answer as to how to handle multi language implementations. It depends on the needs of the client.

Paul.