openverse-frontend icon indicating copy to clipboard operation
openverse-frontend copied to clipboard

Create a cron job to update the locale files used by the CI

Open obulat opened this issue 3 years ago • 0 comments

Problem

The locale files such as the list of all locales and the translation strings for each locale are created on each app build. This is important to keep the translated strings up-to-date in production. However, every CI run also updates the locales and makes a lot of network requests. To minimize the number of network calls made by the CI, #1575 saves the select locale files to the test/locales. Now though the locale files used by the CI are not updated at all.

Description

We should create a Cron job that would automatically update the locale files in test/locales. It could be done monthly. Steps:

  • run pnpm build that would generate the JSON files in the src/locales folder.
  • copy src/locales/scripts/valid-locales.json to test/locales/scripts
  • detect the en.json strings that were removed or added since the last time we saved the locale files (we need to find a good solution for how to do this)
    • remove the deleted strings from test/locales/es.json, test/locales/ru.json, and test/locales/ar.json
    • add the translated versions of the new strings from en.json to test/locales/es.json, test/locales/ru.json, and test/locales/ar.json - this step will require the Google or Amazon translation requests. We could also start by simply adding blank strings for the new keys and logging the list of strings that we need to translate to add them manually - for a start.
    • manually set the translated percentage of ru locale in test/locales/scripts/valid-locales.json to a number lower than 90% (if it is higher) so that it can be used for testing the translation banner.

Alternatives

We could manually copy the files generated in the build step monthly. The problem is that the ar.json file was manually generated by translating en.json strings with Google Translate, so it would break the 100% translated status of the Arabic locale and fail many RTL tests.

Additional context

More discussion on the rationale for the way locales work in the CI is in #1575 and its comments.

Implementation

  • [ ] 🙋 I would be interested in implementing this feature.

obulat avatar Jul 26 '22 05:07 obulat