ZF-11908: Wrong arguments to Zend_Locale_Format::convertNumerals

Description

The documentation (user and inline) says that the arguments to this function are the names of scripts.

But they are not. The arguments are actually the names of numbering systems.

For most locales, the numbering system name is simply a lower-case version of the script name. e.g.

Latn => latn Beng => beng Taml => taml

Upper/lower case are ignored, so the two are interchangeable.

But, for the arabic script, there are two sets of numbering systems. The Arabic language and Farsi both use the arabic script, but with different numerals. For illustration, these are

۰۱۲۳۴۵۶۷۸۹ - Arabic ٠١٢٣٤٥٦٧٨٩ - Farsi

Hence the file Zend/Locale/Data/numberingSystems.xml has two definitions: "arab" and "arabext".

I have confirmed that the code does actually use numbering-system-names, rather than script names. e.g.

echo Zend_Locale_Format::convertNumerals('0123456789', 'latn', 'arab'); // gives Arabic digits echo Zend_Locale_Format::convertNumerals('0123456789', 'latn', 'arabext'); // gives Farsi digits

So,

1) The documentation should be updated to reflect what the code actually does (use numbering system name, not script name)

Here is some sample code which illustrates the correct way to use this function.

To convert $number from $locale1 to $locale2,

$numbering_system1=Zend_Locale_Data::getContent($locale1, 'defaultnumberingsystem'); $numbering_system2=Zend_Locale_Data::getContent($locale2, 'defaultnumberingsystem'); echo Zend_Locale_Format::convertNumerals($number, $numbering_system1, $numbering_system2);

Comments

No comments to display