Search for missing keys in yaml files

    Sometimes open source projects are translated into many foreign languages. On the one hand, this makes them more accessible to a wide range of users, but on the other hand, all these translations need to be supported. Translations are usually divided by yaml-files and selected in a separate directory, the contents of which look something like this: en.yml, ru.yml, de.yml ...
    What I have to see in open source projects is that in a certain period of time someone decided to translate all the texts into their native language, while adding a file of the form xx.yml. The translation is done, everything is fine, but the project does not stand still, new functions are added, the old code is deleted. The person who made the initial translation, in most cases, no longer follows all these movements and does not add new translations each time. People who are contributing code are also not able to translate into all languages ​​that the project supports. It turns out that there are many yml files, the reference of them is usually en.yml. When new people come who want to supplement the missing translations, they are faced with the problem that there are hundreds of lines of text in each file and it is impossible to understand which ones are missing or redundant.
    For these purposes, I wrote a simple jam called Differz , which compares yaml files and shows the missing keys. You can install by simply completing
    gem install differz

    If rbenv is used, then you also need to run
    rbenv rehash

    To show the difference between en.yml and de.yml, you need to run the following line in the console:
    differz show en.yml de.yml

    For example, I launched this application on the popular project activeadmin, which was translated into many languages. Here is the result of comparing en.yml and de.yml:

    The plans were to enable the user to fill in all the missing keys directly from the console. An unwritten edit command will serve for this.

    Also popular now: