openverse-frontend
openverse-frontend copied to clipboard
Create a cron job to update the locale files used by the CI
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 buildthat would generate theJSONfiles in thesrc/localesfolder. - copy
src/locales/scripts/valid-locales.jsontotest/locales/scripts - detect the
en.jsonstrings 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, andtest/locales/ar.json - add the translated versions of the new strings from
en.jsontotest/locales/es.json,test/locales/ru.json, andtest/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
rulocale intest/locales/scripts/valid-locales.jsonto a number lower than 90% (if it is higher) so that it can be used for testing the translation banner.
- remove the deleted strings from
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.