6.0.0-alpha10
5/14/25

[#15081] Language codes get falsely trimmed two two letters
Summary Language codes get falsely trimmed two two letters
Queue Horde Framework Packages
Type Bug
State Unconfirmed
Priority 1. Low
Owners
Requester me (at) marcusbuck (dot) org
Created 12/17/2021 (1244 days ago)
Due
Updated 12/17/2021 (1244 days ago)
Assigned
Resolved
Milestone
Patch No

History
12/17/2021 03:47:51 PM me (at) marcusbuck (dot) org Comment #1
State ⇒ Unconfirmed
Priority ⇒ 1. Low
Type ⇒ Bug
Summary ⇒ Language codes get falsely trimmed two two letters
Queue ⇒ Horde Framework Packages
Milestone ⇒
Patch ⇒ No
Reply to this comment
In the Native Language Support file Nls.php:280 [1] the language code 
is trimmed to two characters. Probably under the assumption that 
language codes are always ISO 639 and all character after that are 
country subtags. But RFC 3282 [2} and RFC 3066 [3] clearly allow three 
letter language codes from ISO 639-2 and some reserved codes.

This excludes languages as important as Cebuano (ceb) with 30 million 
speakers in the Philippines and even misinterprets Cebuano as Chechen 
(ce).

I came across this error when the accept-language mail header for Low 
German (nds) was misreported as North Ndebele (nd).

The correct fix is to allow all valid language codes. That should be 
doable with CLDR. That will probably require some code refactoring. If 
it is not possible to fix this easily, it would be nice if in the 
meantime at least the languages wouldn't be misreported. If a code is 
"unknown" it should be possible to create a dummy 
Horde_Nls_Translation object and just have the language code as output.

[1] <https://github.com/horde/Nls/blob/master/lib/Horde/Nls.php#L280>
[2] <https://datatracker.ietf.org/doc/html/rfc3282>
[3] <https://datatracker.ietf.org/doc/html/rfc3066>

Saved Queries