Implementing CLDR plural rules

Ed Trager ed.trager at gmail.com
Fri Oct 16 14:03:59 CDT 2015


Excellent, Cameron, I will definitely take a look!

And thanks, Mark Davis, I will also take a look at what ICU looks like.



On Fri, Oct 16, 2015 at 1:23 PM, Cameron Dutro <cameron at lumoslabs.com>
wrote:

> Hey Ed,
>
> I recently wrote a parser in Ruby for the plurals syntax (called
> cldr-plurals <https://github.com/camertron/cldr-plurals>) and released it
> open-source. The project contains two emitters - one for Ruby and one for
> Javascript. In fact, the project is designed to accommodate emitters for
> any language, C++ included. I would welcome a pull request if you'd care to
> contribute. If nothing else, the project can serve as an example
> implementation should you decide to write your own version. ICU can of
> course serve you in a similar capacity.
>
> The code emitted by the cldr-plurals emitters requires a runtime capable
> of producing the n, i, v, w, f, and t variables you mentioned, to the level
> of detail specified by TR35. The Ruby and Javascript runtimes are released
> as separate projects and can also be used as a reference when developing
> your own C++ version. Here's
> <https://github.com/camertron/cldr-plurals-runtime-rb/blob/master/lib/cldr-plurals/ruby_runtime.rb>
> the Ruby runtime, and here's
> <https://github.com/camertron/cldr-plurals-runtime-js/blob/master/lib/cldr-plurals/javascript_runtime.js>
> the Javascript one.
>
> -Cameron
>
> On Fri, Oct 16, 2015 at 11:20 AM, Ed Trager <ed.trager at gmail.com> wrote:
>
>> Hi, List,
>>
>> The Unicode Technical Report #35 describes operands that are used for
>> defining the rules used for determining plural forms in different languages
>> (http://unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules
>> ).
>>
>> These operands are defined in table 5.1.1 of that report. These operands
>> ( n, i, v, w, f, and t )  describe not only the numeric value but also the
>> *_formatted appearance_* of the numeric value when, for example, fractional
>> decimal digits are present. For example, "v" describes the "number of
>> visible fraction digits in n, with trailing zeros".
>>
>> My question is: Does any production system exist (e.g., some newer
>> version of ICU perhaps?) or has anyone on GitHub or elsewhere implemented a
>> system which follows these rules to this level of detail?
>>
>> In my cursory glance on Github, I see that there are some projects which
>> purport to automatically convert the CLDR XML source to code, but I think
>> at least some of these only deal with the operand "n" and aspire only to
>> the standard GNU "gettext" internationalization library's quality of plural
>> definitions.  Also, in my cursory glance on GitHub, I did not see any C++
>> class libraries which implement the CLDR style of plural definitions.
>>
>> I am in fact thinking of writing my own C++ class implementation, so
>> that's why I am asking.  From what I can tell, the STL C++ facet stuff also
>> does not implement CLDR-style plural rules; is this assumption correct?
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> CLDR-Users mailing list
>> CLDR-Users at unicode.org
>> http://unicode.org/mailman/listinfo/cldr-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://unicode.org/pipermail/cldr-users/attachments/20151016/9ed57e36/attachment-0001.html>


More information about the CLDR-Users mailing list