How to verify the existence of a translation key before printing?

Since there’s not possible to translate tags (at least i haven’t found anything), i have to do it manually. I decided that the best solution is to put all tags into locale files and just call it throughout the site.

But it is just not possible to keep all translation files up to date. So sometimes i get an error that “translation missing” which is not very good.

How do i check whether or not key exists before printing it?

Actually i came of with kind of solution, but i don’t think it is the best way possible.

{% capture message %}{{ 'group.' | append: group | t }}{% endcapture %}

                          {% if message contains "translation missing" %}
                            {{ group }}
                          {% else %}
                            {{ message }}
                          {% endif %}
2 Likes