Live data from Hacker News

MessageFormat: Unicode standard for localizable message strings

github.com

61–68 of 68 posts

Re: MessageFormat: Unicode standard for localizable message strings

#61
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.

Wow, the in-browser preview is excellent. I first assumed it was just a demonstration and appreciated it very much, but then I realized it was live-editable and was blown away.

Re: MessageFormat: Unicode standard for localizable message strings

#62
post #52

One thing I would really appreciate in this repository (and many like it) would be a simple, short, snippet of code that shows a typical use case of whatever the repo is selling me. Life's too short to dig around in the guts of the repository to find stuff like this out, it should be front and center. I want to know about the ergonomics and hackability of what I'm about to delve into.

You are looking for the marketing page not the GitHub page then: https://messageformat.unicode.org/

Re: MessageFormat: Unicode standard for localizable message strings

#63
post #10

Looking for an expert who knows both libintl/Gettext and MessageFormat. What is the equivalent of xgettext.pl, the file extension for the main catalog file `.po`, the __ function? How does gender work (small example)? How does layering pt_BR on pt_PT work? What is a compelling reason to switch?

https://messageformat.unicode.org/ Lmk if you have further questions!

The site behind that link gives answers to only 2 out of 6 question. If your goal was to promote and teach, then you have failed. If your goal was to demoralise the HN readers and grind the conversation to a stop, then you have succeeded.

Re: MessageFormat: Unicode standard for localizable message strings

#64
post #25

Earlier quoted context omitted.

This post shows a lot of the challenges with localisation, that many seemingly simple tools don't have an answer to: https://hacks.mozilla.org/2019/04/fluent-1-0-a-localization-... (Fluent informed much of the design of MessageFormat 2.)

Indeed, if only it were as simple as “{n} rows”. I18n / l10n is full of things like this, important details that couldn’t be more boring or fiddly to implement.

> Indeed, if only it were as simple as “{n} rows”.

How long till we just have a LLM do it on the fly?

Re: MessageFormat: Unicode standard for localizable message strings

#65
post #63

Earlier quoted context omitted.

https://messageformat.unicode.org/ Lmk if you have further questions!

The site behind that link gives answers to only 2 out of 6 question. If your goal was to promote and teach, then you have failed. If your goal was to demoralise the HN readers and grind the conversation to a stop, then you have succeeded.

Definitely the former, apologies for making it confusing.

> What is the equivalent of xgettext.pl

There is no standard one, although people build their own. The general consensus is that source strings should not be inlined into code. The closest analogy is to "style" vs "class" in HTML/CSS - the clean separation of concerns comes from the "id" being the contract.

You can read more about it here: https://github.com/projectfluent/fluent/wiki/Fluent-vs-gette...

There are attempts to "merge" those two philosophies, by extracting and "generating" slugs as ids. Examples: - https://formatjs.github.io/docs/getting-started/message-extr... - https://lingui.dev/guides/message-extraction - https://app.studyraid.com/en/read/15768/550728/setting-up-th...

I'm fairly skeptical of this approach.

> the file extension for the main catalog file `.po`

In MF1.0 world, the file format is JSON or XML. You encode id=>Message pairs. In Fluent world there is a Fluent (FTL) file format. In MF2.0 the format itself is, again, message scoped. On top of it there's a proposal by Mozilla to create MessageResource - https://github.com/w3c/i18n-discuss/blob/gh-pages/explainers... and that may feed into DOM L10n - https://github.com/mozilla/explainers/blob/main/dom-localiza...

> the __ function?

see the (1) and links to "generated ids".

> How does gender work (small example)?

MF 1.0:

``` {GENDER, select, male {He answered} female {She answered} other {They answered} } ```

Fluent: ``` user-answered = { $gender -> [male] He answered. [female] She answered. *[other] They answered. } ```

> How does layering pt_BR on pt_PT work?

MF does not prescribe fallback behavior. It also more popular to treat each locale as "complete" and fill "gaps" at build time. So at runtime you have `pt-BR` which has pt-BR strings and missing ones "completed" from `pt` (parent locale).

Fluent has a "resource manager" (simple one like this: https://github.com/projectfluent/fluent-rs/tree/main/fluent-... or more complex like Mozilla L10nRegistry), which can fallback at runtime, allowing for what we call "partial locales" which can roll out to production with gaps and the resource manager will fetch the fallback strings from the parent locale.

> What is a compelling reason to switch?

If you and your users are happy with gettext, none!

If either of those groups complain, there may be many: - https://github.com/projectfluent/fluent/wiki/Fluent-vs-gette...

Hope that helps!

Re: MessageFormat: Unicode standard for localizable message strings

#66
post #18

Earlier quoted context omitted.

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

No, gettext scales very badly, both vertically (larger systems) and horizontally (locales with rich grammatical forms like declensions etc.) We (authors of Fluent and collaborators on MessageFormat 2.0) wrote this explainer which you may find informative - https://github.com/projectfluent/fluent/wiki/Fluent-vs-gette...

Thanks, I'm a decades-long user of gettext from both developer and translator point of view, and have encountered several of the drawbacks to some extent.

It's very good, and has certainly been good enough for most practical purposes, but innovation needs to happen, and things can certainly get better. Thanks for your work in this direction!

Re: MessageFormat: Unicode standard for localizable message strings

#67
post #63

Earlier quoted context omitted.

The site behind that link gives answers to only 2 out of 6 question. If your goal was to promote and teach, then you have failed. If your goal was to demoralise the HN readers and grind the conversation to a stop, then you have succeeded.

Definitely the former, apologies for making it confusing. > What is the equivalent of xgettext.pl There is no standard one, although people build their own. The general consensus is that source strings should not be inlined into code. The closest analogy is to "style" vs "class" in HTML/CSS - the clean separation of concerns comes from the "id" being the contract. You can read more about it here: https://github.com/p…

Thank you, this was a good answer and it provided the necessary insight. We will include MessageFormat resp. its ecosystem into reevaluating which l10n system we should use at the next upcoming opportunity in the hopes that the missing parts will have arrived by then.

Re: MessageFormat: Unicode standard for localizable message strings

#68

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.

Yep. Mozilla is planning an auto converter from Fluent to MF2.0 once we stabilize it.

It is great to hear a confirmation, though the core of the question was more about when is that roughly forecast to happen rather than if. :)
Post reply on HN