Uploaded image for project: 'stripes-cli'
  1. stripes-cli
  2. STCLI-158

compile translation files to AST for efficiency



    • Task
    • Status: Closed (View Workflow)
    • P3
    • Resolution: Done
    • None
    • None
    • None
    • stripes-force 107, stripes-force 108, stripes-force 110, stripes-force 111
    • Stripes Force


      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):
        exports.compile = (m) => m;
      • parse the translations for each locale:
        $ yarn formatjs-compile translations/stripes-core/en.json --ast --out-file translations/stripes-core/en.ast.json --format ./util/react-intl-formatter.js 
      • update Jenkinsfile┬áso compilation and testing are both handled by runScripts, in order:
        -  runTest = 'yes'
        -  runTestOptions = '--karma.singleRun --karma.browsers ChromeDocker --karma.reporters mocha junit --coverage'
        +  runScripts = [
        +   ['formatjs-compile': ''],
        +   ['test':'--karma.singleRun --karma.browsers ChromeDocker --karma.reporters mocha junit --coverage'],
        +  ]

      TestRail: Results


          Issue Links



                rberger Ryan Berger
                zburke Zak_Burke
                0 Vote for this issue
                4 Start watching this issue



                  TestRail: Runs

                    TestRail: Cases