Locale/localeapp

Add option to remove keys not used anymore

Kosmas opened this issue · 1 comments

After using the translations for some time, keys that have been removed from the current translation still exist on the web application.
Add an option to be able to remove them.
Better synchronization between current local translations and ones on web application.

ryanb commented

For anyone wanting to do this, I've had good success using i18n-tasks to manage unused locales.

You can run i18n-tasks remove-unused to remove locales which are not used. This only removes the locales locally, not on localeapp.

After running that command, ensure that all specs pass since there may be dynamic locales that i18n-tasks does not detect. You can add an i18n-tasks-use comment to define static versions of the dynamic locales. It's best to configure Rails and I18n to raise an exception if a locale is missing in the test environment.

Once you're happy with the results, revert the i18n-tasks removal and pipe it through localeapp instead. Something like this.

i18n-tasks unused --format keys | grep ^en\. | sed 's/^en\./sleep 5; localeapp rm /' | sh

That should remove each key that i18n-tasks considers unused. Note the sleep 5 call, this is because localeapp has a fairly strict request rate limit and AFAIK only supports removing one key at a time.