-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JS package with pattern parsers & serializers #46
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you thought about putting the JS library into a separate repository? It feels a bit odd to keep the Python version of the library in /moz/l10n
when the JS version is in /js
.
Yes, but decided that having it in the same repo is the best way to ensure that the functionalities that are supported by both the Python & JS implementations continue to match. If we need to e.g. add a field to the JSON Schema or change how XLIFF patterns are represented, we can (and should!) apply the change to both implementations in the same PR.
I can move the Python version to a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
I'll leave that decision to you - mostly wanted to understand if you've considered a separate repo. |
Adds the start of a JS library in parallel with the Python one, primarly to fulfil the needs of the Pontoon frontend.
Includes support for the following message pattern formats:
android
: Android string resourcesfluent
: Fluent (without internal selectors)mf2
: MessageFormat 2.0plain
: Patterns without placeholderswebext
: WebExtensions (messages.json)xliff
: XLIFF 1.2, including XCode customizationsThe tooling for
android
andxliff
depends onDOMParser
,XMLSerializer
, and related classes which are available in browser environments. The parser forfluent
depends on the@fluent/syntax
package, and the parser formf2
depends on themessageformat
package.The primary entry points are:
These functions convert a flat message pattern between its data structure representation, and the format's serialized form. The data structure is the same as the one used by
moz.l10n.message.message_from_json
andmoz.l10n.message.message_to_json
.A CI test action is included, and the package should be ready to publish on npm.