Search code examples
vue.jsinternationalizationvue-i18n

VueI18n check if translation exists


Is there a way to check if translation exist?

<p v-if="$t('some_key')">{{ $t('some_key') }}</p>

In this case if there is no translation it will print 'some_key'. Maybe there is a way to configure global fallback?


Solution

  • You can use the $te method.

    Example usage:

    <p v-if="$te('some_key')">{{ $t('some_key') }}</p>
    

    https://kazupon.github.io/vue-i18n/api/#te