Live data from Hacker News

MessageFormat: Unicode standard for localizable message strings

github.com

11–20 of 68 posts

Re: MessageFormat: Unicode standard for localizable message strings

#11
One practical thing I appreciated about MessageFormat is how it eliminates a bunch of conditional UI logic.

I used to write switch/if blocks for:

• 0 rows → “No results” • 1 row → “1 result” • n rows → “{n} results”

Which seems trivial in English, but gets messy once you support languages with multiple plural categories.

I wasn’t really aware of how nuanced plural rules are until I dug into ICU. The syntax looked intimidating at first, but it actually removes a lot of branching from application code.

I’ve been using an online ICU message editor (https://intlpull.com/tools/icu-message-editor) to experiment with plural/select cases and different locales helped me understand edge cases much faster than reading the spec alone.

Re: MessageFormat: Unicode standard for localizable message strings

#12
post #3

The meeting notes in the repo was a nice surprise. Overall looked great, striking a good balance. .input {$var :number maximumFractionDigits=0} .local $var2 = {$var :number maximumFractionDigits=2} .match $var2 0 {{The selector can apply a different function to {$var} for the purposes of selection}} * {{A placeholder in a pattern can apply a different function to {$var :number maximumFractionDigits=3}}} Oof, that's a…

English has just singular and plural: one car, two cars, three cars (and zero cars).

Some languages have more variations. E.g. Czech, Slovene and Russian has 1, 2-4 and 5 as different cases.

Personally I think the syntax is too brittle. It looks too much like TeX code and it has the lisp like deal with lines ending with too many } braces.

I would separate it into two cases: simple strings with just simple interpolation and then a more fuller markup language, more like a simplified xml.

There are more example code at https://github.com/unicode-org/message-format-wg/blob/main/d...

Re: MessageFormat: Unicode standard for localizable message strings

#13
Does anyone know the ETA of MessageFormat 2.0? I am aware of the effort since pre-COVID times. I recall that some of the developers behind Mozilla Fluent have been among the people working on MF 2.0, and it’d be great to know whether Fluent and ICU MF are going to be interoperable in foreseeable future.

Re: MessageFormat: Unicode standard for localizable message strings

#14
post #3

The meeting notes in the repo was a nice surprise. Overall looked great, striking a good balance. .input {$var :number maximumFractionDigits=0} .local $var2 = {$var :number maximumFractionDigits=2} .match $var2 0 {{The selector can apply a different function to {$var} for the purposes of selection}} * {{A placeholder in a pattern can apply a different function to {$var :number maximumFractionDigits=3}}} Oof, that's a…

English has just singular and plural: one car, two cars, three cars (and zero cars). Some languages have more variations. E.g. Czech, Slovene and Russian has 1, 2-4 and 5 as different cases. Personally I think the syntax is too brittle. It looks too much like TeX code and it has the lisp like deal with lines ending with too many } braces. I would separate it into two cases: simple strings with just simple interpolati…

Oh, the language aspect gets a lot worse than that. They explicitly have a non-goal of "all grammatical features of all languages", but the "common" cases are hard enough. From https://github.com/unicode-org/message-format-wg/blob/main/s... :

  .local $hasCase = {$userName :ns:hasCase}
  .match $hasCase
  vocative {{Hello, {$userName :ns:person case=vocative}!}}
  accusative {{Please welcome {$userName :ns:person case=accusative}!}}
  * {{Hello!}}
But if anyone can find a good compromise, it's the Unicode team.

Re: MessageFormat: Unicode standard for localizable message strings

#15
post #9
post #7

Looks alot like mozilla's project fluent, atleast in the basic use case. https://projectfluent.org/ I wonder why it hasn't been adopted more widely.

I often wonder this myself, this really should be a standard by now.

I can't speak for the status quo, but for at least the first ~5 years (so until 3 years ago when I last attempted to use it), the JS implementation of Fluent was a mess. Constant issues with incomplete API, wrong TS typings (which at that point were external) and build/bundling issues to the point where we opted for a homebrew solution.

I imagine that I probably wasn't the only one driven away by that (and I gave it many attempts!).

Re: MessageFormat: Unicode standard for localizable message strings

#16
post #7

Looks alot like mozilla's project fluent, atleast in the basic use case. https://projectfluent.org/ I wonder why it hasn't been adopted more widely.

They seems to be a strong overlap of people behind both projects, so that likely explains the similarities.

Re: MessageFormat: Unicode standard for localizable message strings

#18
post #11

One practical thing I appreciated about MessageFormat is how it eliminates a bunch of conditional UI logic. I used to write switch/if blocks for: • 0 rows → “No results” • 1 row → “1 result” • n rows → “{n} results” Which seems trivial in English, but gets messy once you support languages with multiple plural categories. I wasn’t really aware of how nuanced plural rules are until I dug into ICU. The syntax looked int…

Did not gettext have this for decades? https://www.gnu.org/software/gettext/manual/html_node/Plural...

Re: MessageFormat: Unicode standard for localizable message strings

#19
post #11

One practical thing I appreciated about MessageFormat is how it eliminates a bunch of conditional UI logic. I used to write switch/if blocks for: • 0 rows → “No results” • 1 row → “1 result” • n rows → “{n} results” Which seems trivial in English, but gets messy once you support languages with multiple plural categories. I wasn’t really aware of how nuanced plural rules are until I dug into ICU. The syntax looked int…

I checked the spec and don't get that really. Something should specify the formula for choosing the correct form (ie 1 for 21 in Slavic languages) and the format isnt any better compared to the gettext of 30 years ago

Re: MessageFormat: Unicode standard for localizable message strings

#20
post #18
post #11

One practical thing I appreciated about MessageFormat is how it eliminates a bunch of conditional UI logic. I used to write switch/if blocks for: • 0 rows → “No results” • 1 row → “1 result” • n rows → “{n} results” Which seems trivial in English, but gets messy once you support languages with multiple plural categories. I wasn’t really aware of how nuanced plural rules are until I dug into ICU. The syntax looked int…

Did not gettext have this for decades? https://www.gnu.org/software/gettext/manual/html_node/Plural...

Gettext has everything, it just takes knowing five languages to understand what to use for
Post reply on HN