#1 2014-05-08 16:50:18

kochin
Member
Registered: 2013-07-23
Posts: 13

language codes can't have upper case letters

When entering language codes in the admin backend, they have to be all lower case to work. Is it intentional?

For example, I tried zh-TW as a language code and got a 404 page when switched to that language. After I changed it to zh-tw, the web site shows up as expected. Similarly, zht as a language code works but zhT doesn't.

Offline

#2 2014-05-08 18:09:32

kochin
Member
Registered: 2013-07-23
Posts: 13

Re: language codes can't have upper case letters

Turned on the DEBUG logging, and found this message in the log when used zh-TW as the language code:

DEBUG - 2014-05-08 11:15:23 --> Router: The key "zh-tw" was not a valid language key.
DEBUG - 2014-05-08 11:15:23 --> Router: Applying the language key "en".

Looked into the source code and found the function validate_lang_key() which handles the validation. The first line in that function is

$key = strtolower(trim((String) $key, '/\\ '));

That code transforms the language code into lower case, and later returns that modified code to the caller of the function.

However, when I looked into the database, the language code stored in there is zh-TW. The configuration file language.php also has zh-TW in its $config['available_languages'] and $config['online_languages']. That makes me wonder whether there are some inconsistencies in the program on how language code are handled. Can it be that some places use lower case version of the language code and others use unmodified version?

Offline

#3 2014-05-09 16:31:47

kochin
Member
Registered: 2013-07-23
Posts: 13

Re: language codes can't have upper case letters

I changed the first line of the function validate_lang_key() in file application/core/Router.php from

$key = strtolower(trim((String) $key, '/\\ '));

to

$key = trim((String) $key, '/\\ ');

With some limited tests, it seems working fine with language codes with upper case letters such as zh-TW. I don't have enough insights into how the language handling works in Ionize to say everything will be fine with the change.

Offline

#4 2014-05-16 19:41:03

Michel-Ange
Ionize Core Team
From: Paris, France
Registered: 2010-03-22
Posts: 927
Website

Re: language codes can't have upper case letters

This will be corrected in the 1.0.6.1.

But "zh-TW" will become "zh-tw", as uppercase in URL is not a good thing (a lot of papers speak about this, some research of the web will convince you).

Thanks a lot for the report !


Inspiration & Innovation : Websites by Partikule, Agence Web Paris

Offline

#5 2014-05-22 18:21:11

kochin
Member
Registered: 2013-07-23
Posts: 13

Re: language codes can't have upper case letters

Agree. Lower case is definitely better for using in URL strings.
Ionize should simply be consistent and force all the language code to be lower case everywhere in the system.
Thanks.

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations