Live data from Hacker News

Show HN: a18n – Automated I18n JavaScript Solution

github.com

21–27 of 27 posts

Re: Show HN: a18n – Automated I18n JavaScript Solution

#21
This is great. As someone who spent a great deal of time working on i18n with JS for my own software the current state of the art is not amazing. A lot of half finished and abandoned projects, many of which don't entirely work or conform to pre-existing standards. Most don't play well with newer web frameworks and those that do tend to be very limited.

Finding a good solution for VueJS, which has it's own .vue files was particularly hard. I ended up building on top an existing i18n extract tool and integrating it with the VueJS compiler to extract both HTML and JS translations.

What I'd like to see, that I have not seen anywhere (other than a broken and not currently maintained Webpack module) is a plugin for Babel or Typescript compilers that allows the compiler to compile translations into the final output packages and produce one for each language. I think this is preferable to loading translations at runtime and swapping them in.

Re: Show HN: a18n – Automated I18n JavaScript Solution

#23
post #17
post #8

Shameless self-promotion hijack: https://github.com/whyboris/JSON-i18n-Editor A web interface for letting your team translate JSON i18n files - in case you store your i18n in JSON. See the live demo: link on the GitHub page.

Nice. Being a happy customer of https://poeditor.com I'd like to point out that there's also a service for this out there.

I tried POEditor -- it has nice features that my tool does not. I'd like to think my tool is a good-enough free alternative for many cases.

Re: Show HN: a18n – Automated I18n JavaScript Solution

#24

This is great. As someone who spent a great deal of time working on i18n with JS for my own software the current state of the art is not amazing. A lot of half finished and abandoned projects, many of which don't entirely work or conform to pre-existing standards. Most don't play well with newer web frameworks and those that do tend to be very limited. Finding a good solution for VueJS, which has it's own .vue files…

Will definitely look into .vue support!

But for compile translations (per-language), I'm not so sure if added performance can justify introduced complexity (for users' build/serve workflow).

Re: Show HN: a18n – Automated I18n JavaScript Solution

#25
post #4

Nice work! What's the difference between this and .po/.mo files and the ugettext standard?

Update:

As far as I know, this should be a subset of the PO format (http://pology.nedohodnik.net/doc/user/en_US/ch-poformat.html....).

The file format used by a18n is JSON, where its keys are extracted from code (using `a18n extract`) into one of these formats:

- "static text"

- "dynamic text with one variable: %s"

- "dynamic text with multiple variables: %1, %2, %3"

- "#some.text.id" or "xxx#some.text.id" -- user manually assign text an ID with: a18n("xxx", {_: "some.text.id"})

(It worth noting that my company further converts this JSON to Excel before sending to translators)

Re: Show HN: a18n – Automated I18n JavaScript Solution

#26
post #19
post #4

Nice work! What's the difference between this and .po/.mo files and the ugettext standard?

Thank you for asking this question - it lead me to find this library (and I think the quickstart highlights some differences to how the gnu gettext standard could be leveraged in js/ts vs a "propiatary" solution based on json) : https://ttag.js.org/ https://ttag.js.org/docs/quickstart.html

Thanks for feedback! It looks like a decent lib and I would recommend anyone who need richer i18n support (like plural forms) take a look.

As for a18n, it's a deliberate choice to use current format (JSON with extracted key/value pair) instead of standard like ICU messageformat. Here are reasons:

1. This lib is built to enable automated i18n workflow for existing projects (~200kloc), with minimal human interfere and impose minimal complexity for build configuration, in this regard current format is working great.

2. This lib is used by both projects, plugins and components in our company, so to keep its footprint down (in case it's not deduped by bundler), it means fewer features (like plural forms, date, list) are supported, and...

3. ...we originally planned to add support for ICU messageformat if these features are desired. But after two years in production, we found the demand is not too strong to justify the cost.

Re: Show HN: a18n – Automated I18n JavaScript Solution

#27
post #9

Earlier quoted context omitted.

This is like a11y - "accessibility" a[eleven letters]y - https://www.a11yproject.com/

As abbreviations go, a11y is a quiet masterpiece, being simultaneously a numeronym, a homograph, a domain-relevant noun, and an Internet in-joke. I'd hope that whosoever dreamed it up, went home for lunch and never returned. With the best will in the world, I'd struggle to rate this a18n in the same ballpark of poetic genius as a11y .

a8y
Post reply on HN