compile translation files to AST for efficiency

Description

As noted in the formatjs documentation and in FOLIO's javascript console, translation values should be precompiled for efficiency:

[@formatjs/intl] "defaultRichTextElements" was specified but "message" was not pre-compiled.
Please consider using "@formatjs/cli" to pre-compile your messages for performance.
For more details see https://formatjs.io/docs/getting-started/message-distribution

Compiling the messages is easy, but there's a bit of grunt work to configure it all correctly that, should be centralized into stripes-cli so it can be managed automatically as part of the stripes build command. We'll also need to update stripes-core to use the pre-compiled files when they are available and to fall back to the current, uncompiled files when they are not available.

For an individual repository for an individual locale, the steps looks like this:

  • add @formatjs/cli as a dev-dep

  • add a translation-compilation hook to the package.json scripts section, e.g. "formatjs-compile": "formatjs compile"

  • provide a formatter (our translation-file syntax exactly matches the required output syntax, so this is dead simple):

  • parse the translations for each locale:

  • update Jenkinsfile so compilation and testing are both handled by runScripts, in order:

Environment

None

Potential Workaround

None

Attachments

2

relates to

Checklist

hide

TestRail: Results

Activity

Show:

Zak Burke May 28, 2021 at 10:09 AM

, strictly speaking, we didn't put a deadline on this work so it is not required. That said, from a dev point of view, the change is small, low risk (no code changes), and improves the DX by cleaning up the console. From an end-user's point of view, there is no impact except a minor performance improvement.

Denys Bohdan May 28, 2021 at 9:57 AM

is this work needed for Juniper? Do we need to release modules that only these changes since last release?

Peter Murray April 9, 2021 at 4:11 PM

Sounds good—thanks for the details, .

Zak Burke April 9, 2021 at 2:12 AM

, has done the work to automate the process of compiling the existing locale.json files into AST files so there shouldn't be any work for devops, and all devs will have to do is configure the compilation script in each repo, a one-time config task.

Peter Murray April 7, 2021 at 1:41 PM

I looked in Lokalise, and there isn't an "AST" format available.  Hopefully this isn't too much of a burden for the developers/devops teams to create.

Done

Details

Assignee

Reporter

Priority

Sprint

Development Team

Stripes Force

TestRail: Cases

Open TestRail: Cases

TestRail: Runs

Open TestRail: Runs
Created November 23, 2020 at 12:18 PM
Updated May 12, 2023 at 1:52 PM
Resolved April 12, 2021 at 12:34 PM
TestRail: Cases
TestRail: Runs