News for hackers. Stuff that matters.
Re:Fluent 1.0: a localization system for natural-sounding tr... by quelltext on Wednesday April 17, 2019 @05:15AM (#19680960)
In the Czech example, how is it obvious that `few` stands for 2, 3, 4? Is that just how the concept of "few" (note the English term) is defined and understood by all Cezch speakers and thus this language specific meaning is encoded by Mozilla to map to the range 2-4?

My point is that while there might be a concept of "few" that does map uniquely to that range, I am not sure naming the keyword "few" is the right name for this.

Quite honestly it would be easier to understand if it were explicitly referring to the range. After all these strings are provided specific to a language anyway. As such why not encode the rules in them explicitly instead of relying on keywords?

Or are those merely user defined abstractions to accomplish reuse? I guess it would help, but I'm still not sure why this needs a whole new framework.

Re:Fluent 1.0: a localization system for natural-sounding tr... by stasm on Wednesday April 17, 2019 @05:20AM (#19680987)
(Author of the blog post here.) Great question, thanks! Unicode defines six categories of plural forms: zero, one, two, few, many, and other. The names of these categories always appear in English. Unicode also maintains a collection of all mappings of numerical rules to these categories, for all languages supported by the CLDR. See http://www.unicode.org/cldr/charts/latest/supplemental/langu... for the mapping corresponding to the Czech grammar.
Re:Fluent 1.0: a localization system for natural-sounding tr... by Zenbit_UX on Wednesday April 17, 2019 @09:42AM (#19682439)
Care to comment about how it might handle one bold word or a link mid sentence?
Re:Fluent 1.0: a localization system for natural-sounding tr... by stasm on Wednesday April 17, 2019 @10:36AM (#19682921)
When Fluent formats translations, it returns simple strings (in the sense of primitive computer types). They can include markup which is parsed by a higher-level abstraction responsible for actually showing the translations somewhere in the UI. Take a look at https://github.com/projectfluent/fluent.js/wiki/DOM-Overlays in the experimental fluent-dom package, and their React equivalent, https://github.com/projectfluent/fluent.js/wiki/React-Overla....
Re:Fluent 1.0: a localization system for natural-sounding tr... by quelltext on Wednesday April 17, 2019 @05:27AM (#19681025)
Ah, if this is building on top of existing rules / standards that makes total sense.
Re:Fluent 1.0: a localization system for natural-sounding tr... by sanqui on Wednesday April 17, 2019 @05:22AM (#19681005)
Czech speaker here. When stating a plural in the nominative form, counts of 2-4 items always use the nominative plural and counts of 5+ items use the genitive plural. This concept is understood by Czech speakers natively and doesn't have any description. "Few" is therefore just a descriptive name chosen by the Fluent developers, and probably covers other languages with a similar concept.
Re:Fluent 1.0: a localization system for natural-sounding tr... by aembleton on Wednesday April 17, 2019 @01:30PM (#19684580)
Few is languages specific, so the logic for it should live with the language. Another language might have a plural for 3-6 but you would then need another way to describe it. I've mentioned this in another comment, but I think a range would be better such as 2..4 or 3..6
Re:Fluent 1.0: a localization system for natural-sounding tr... by chungleong on Wednesday April 17, 2019 @07:10AM (#19681486)
The rules for cardinal numbers in Slavic languages are quite complex. "few" is not just 2, 3, 4, but any number less than 100 ending in 2, 3, 4. You have to use a function to handle the situation. "few" is basically the function name, which is as good as any.
Re:Fluent 1.0: a localization system for natural-sounding tr... by bzbarsky on Wednesday April 17, 2019 @02:37PM (#19685227)
It's not "less than 100 ending in 2, 3, 4". It's "2, 3, or 4 mod 10, but not 12, 13, 14 mod 100".

So for example "1002" is "few" in this sense (even though it's bigger than 100) but "14" is not, even though it's less than 100 and ends in 4.

Re:Fluent 1.0: a localization system for natural-sounding tr... by zbraniecki on Wednesday April 17, 2019 @03:52PM (#19685872)
For ya'll dabbing into the list of rules - feel free to use the Unicode Plural Rules list as a reference point - http://www.unicode.org/cldr/charts/33/supplemental/language_...

It's a great abstraction that makes a lot of Fluent easier :)

Re:Fluent 1.0: a localization system for natural-sounding tr... by chungleong on Wednesday April 17, 2019 @04:38PM (#19686294)
You're right. I forgot about the teens. I don't know about Czech, but in Polish the nominative plural isn't used for numbers higher than 100. "1024 bajtów" and not "1024 bajty". If I remember the rules correctly.
Re:Fluent 1.0: a localization system for natural-sounding tr... by bzbarsky on Thursday April 18, 2019 @12:35AM (#19688732)
That's a good point. The rules I described are for Russian, and other Slavic languages may differ. In particular, looks like Polish is pretty similar to Russian here at least in terms of where the category boundaries are, but Czech is different.

As far as the cases used go, 1024 would take the genitive singular in Russian. 1025 would take the genitive plural. 1021 would take the nominative singular. Nominative plural is not used at all when counting things in Russian.

Re:Fluent 1.0: a localization system for natural-sounding tr... by aembleton on Wednesday April 17, 2019 @01:28PM (#19684561)
This confused me too. To take the example, I'd prefer the following:

  tabs-close-warning-multiple = {$count ->
      [2..4] Chystáte se zavřít {$count} panely. Opravdu chcete pokračovat?
     *[] Chystáte se zavřít {$count} panelů. Opravdu chcete pokračovat?
  }
Specify a range (2..4). The second option shouldn't need to match as it is the default value anyway (signified by the *)
Re:Fluent 1.0: a localization system for natural-sounding tr... by stasm on Thursday April 18, 2019 @01:51PM (#19693127)
The (2..4) range would work for Czech in this example (if I'm reading the CLDR right), but I'm afraid it wouldn't be sufficient for languages with more complex plural rules. Take the rule that returns "one" in Latvian, for example:

    n % 10 = 1 and
      n % 100 != 11 or
    v = 2 and
      f % 10 = 1 and
      f % 100 != 11 or
    v != 2 and
      f % 10 = 1
…where n is the absolute value of the number, f is the visible fractional digits with trailing zeros, and v is _the number_ of visible fraction digits with trailing zeros. Some rules can get even more complex than that; see [0] and [1].

It's safer and more robust to rely on the plural categories defined by the Unicode: (zero | one | two | few | many | other), and by the APIs provided by the platform (ICU, Intl.PluralRules, etc.).

[0] http://www.unicode.org/cldr/charts/latest/supplemental/langu...

[1] http://unicode.org/reports/tr35/tr35-numbers.html#Operands

Re:Fluent 1.0: a localization system for natural-sounding tr... by stasm on Thursday April 18, 2019 @01:55PM (#19693171)
> The second option shouldn't need to match as it is the default value anyway (signified by the *)

That's an interesting suggestion! Right now, the identifier between the brackets is required, but we could relax this in the future. In 1.0, we erred on the side of more conservative and explicit design, to improve the readability and discoverability of the syntax for translators.