Currently we're using language codes in the form
fr-CA
where fr is the lower case two-digit language code (French) and CA is the upper case two-digit country code.
This form of language code is described as having a primary 'tag' - the two-digit language code - and a 'subtag' for a 'region'--in this case, Canada.
However, Drupal core uses all lower case for this type of language code. E.g.:
pt-br
for Brazilian Portuguese.
To keep with core, maybe we should also switch to all lower case.
It's worth determining what common practice is. All the examples I find on W3C documents use upper case for the country-code "region" subtags.
http://www.w3.org/International/articles/language-tags/
See also a search for "region" subtags here:
http://people.w3.org/rishida/utils/subtags/index.php?searchtype=1&search...
It seems likely that both forms are accepted, but I'd like to confirm this before making the change.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | country_code_lowercase.patch | 5.68 KB | recidive |
Comments
Comment #1
nedjoConfirmed that language codes are to be considered case insensitive.
http://www.w3.org/International/articles/language-tags/ :
http://www.ietf.org/rfc/rfc3066.txt (the standard referenced in the above w3 doc):
So we should both (a) switch to all lower case (for consistency with Drupal core) and (b) accept both lower and upper case when matching (i.e., be case insensitive).
Work will include:
strtolower()on input to match to lower case.Comment #2
recidive commentedThe update path may be more complex than that, since there are several modules that stores languages and use them for matching languages in languages table. Some of them may not be case insensitive when matching.
In core, languages fields are: languages.language, node.language and locales_target.language, there is also the language_default variable.
Comment #3
recidive commentedI guess we can just have country_code generate new languages lowercased.
Then make it insensitive when matching languages.
What do you think?
Roughed in a patch to do that.
Comment #4
catchSo is the idea to leave existing languages created by country code with the 'en-CA' format? Presumably since we're just doing this for consistency that ought to be fine - and safer than an incomplete update path.
Comment #5
catchDid some testing with this and committed #3. Moving to active needs more info in case we need to discuss an upgrade path further.