vube / i18n

golang package for basic i18n features, including message translation and number formatting
MIT License
66 stars 20 forks source link

Plurals and rule files. #5

Open aries1980 opened 9 years ago

aries1980 commented 9 years ago

Hi, I'm experimenting with your nice module. I would have three questions:

  1. How do you specify multiple plural versions (e.g. for Russian translation) in the language files?
  2. In the rule files you don't use UTF8 therefore it is hard to read. Is there a technical reason why you used textual representation?
  3. Is there a reason why you picked a different file format than Portable Object (PO)? For PO there are already number of translation tools such as POEdit or KBabel and online services such as Transifex.
verkestk commented 9 years ago

Hi Janos,

Let me see if I can answer your questions.

  1. How do you specify multiple plural versions (e.g. for Russian translation) in the language files?

There's an example for french in https://github.com/vube/i18n/blob/master/data/messages/fr.yaml

Here's UNIT_DAY in Russian: {n} день|{n} дня|{n} дней|{n} дня

That is each form (one|few|many|other) separated by pipes.

  1. In the rule files you don't use UTF8 therefore it is hard to read. Is there a technical reason why you used textual representation?

I agree! As your third question addresses, we use yaml for our translations data (I'll get to that in a bit). We source our data from the CLDR (http://cldr.unicode.org/). Our internal tool for getting this data out of CLDR xml into our yaml is written in go (of course!) and uses the goyaml (https://github.com/go-yaml/yaml) package. I don't know if this is still an issue with goyaml, but at the time that we did this goyaml marshalled unicode characters into what you see. While readable characters would be preferable, this representation still worked. Related on stackoverflow: http://stackoverflow.com/questions/21696845/output-unquoted-unicode-in-go

If goyaml gets a fix for this (or maybe it already has?), I'd love to get these files updated.

  1. Is there a reason why you picked a different file format than Portable Object (PO)? For PO there are already number of translation tools such as POEdit or KBabel and online services such as Transifex.

There is a reason. I evaluated many formats, including PO. We had been using JSON, which was working pretty well for us. However, we wanted the ability to put comments in. So, JSON was out. Some tooling we were evaluating at the time had support for YAML. What it came down to was personal preference - that's it. Support for PO would be a nice feature for this package - Either direct support for loading these file types or a tool for translating them into the yaml required by the package.

I'm not contributing to this package anymore, but there are still vube team members who are monitoring and approving pull requests.