mozilla / fxa

Monorepo for Mozilla Accounts (formerly Firefox Accounts)
https://mozilla.github.io/ecosystem-platform/
Mozilla Public License 2.0
589 stars 212 forks source link

Migrate .po strings to .ftl (a one time script) #7459

Closed data-sync-user closed 3 years ago

data-sync-user commented 3 years ago

The new settings.ftl file duplicates a lot of the strings that already exist in client.po and server.po. In order to support our volunteer localizers we should put some effort into pre-populating what we can in the new .ftl file from the old .po files.

This doesn't need to be 100% of strings - a good threshold could be all the plain strings (ie. nothing with variables, substitutions, HTML, or plural forms). The majority of strings on FxA are short and simple.

This likely means parsing the two .po files and the .ftl file and comparing the strings in a script.

Babel is a common library for parsing gettext files in Python. fluent.syntax is a parser for Fluent files.

I suspect those two will be the fastest path forward here, but in case it helps:

Fluent Migration is a library that translates .dtd and .properties files to fluent, transforming them with recipes. Since we are focused on simple strings I feel like not supporting .po and trying to squeeze everything through recipes might make this more complicated than it needs to be, but I didn't investigate deeply and this might be the way to go.

Axel helped Bedrock migrate to ftl using recipes at https://github.com/mozilla/bedrock/pull/8087 .

┆Issue is synchronized with this Jira Task ┆Issue Number: FXA-2998

data-sync-user commented 3 years ago

➤ Barry Chen commented:

We can do this in js/ts with https://www.projectfluent.org/fluent.js/syntax/ ( https://www.projectfluent.org/fluent.js/syntax/ ) and https://github.com/smhg/gettext-parser ( https://github.com/smhg/gettext-parser )

data-sync-user commented 3 years ago

➤ Barry Chen commented:

I have a WIP repo/branch over at https://github.com/chenba/po2ftl/blob/main/src/index.ts. ( https://github.com/chenba/po2ftl/blob/main/src/index.ts. )

settings.ftl itself is being changed in https://jira.mozilla.com/browse/FXA-2934.

data-sync-user commented 3 years ago

➤ Jared Hirsch commented:

It turns out the great majority of the strings have been modified, so this migration work isn't worth doing.