openverse-frontend
openverse-frontend copied to clipboard
Add a CI step to check for locale completeness
Problem
We are using Vue-i18n for translations. With it, it is easy to use a key that doesn't exist in the locale file or to forget to remove a key that is not used anymore. This can lead to incorrect texts on the pages or even errors.
Description
We should re-add a CI step that checks the locale file for missing or unused keys. The steps that will need to be done are:
-
Add the following code to
.github/workflows/ci.yaml(removed in #1575): https://github.com/WordPress/openverse-frontend/blob/f3f03b4039035f8e7887cde99460d7a45fd6b5d1/.github/workflows/ci.yml#L66-L76 -
Update the
package.jsoni18n:checkscript to add--ciflag to it. -
The largest set of work is to replace all the dynamic keys (such as
filters.${filterType}.title) with static ones (likefilters.licenses.title) to prevent them from being reported as unused.
Alternatives
We can regularly run the i18n:check manually.
Additional context
Prior to #1575, we had the Check translations step that logged the report with the missing/unused keys but would not fail the CI. The reason for it is that vue-i18n-extract that we used for it does not compile the templates. So, when we have a dynamic key like i18n.t(filters.${kebab(filterType)}.title), all its variants are reported as missing.
See https://github.com/WordPress/openverse-frontend/pull/1575#issuecomment-1196707071 for even more context on this.
Implementation
- [ ] 🙋 I would be interested in implementing this feature.