javisperez/vuetranslate

Use in variable

TheoLecoq opened this issue · 2 comments

Is is possible to use the translation in a variable? Something like $('#error').text( {{ t('error min max') }} ); ?

If I understand your question correctly: Yes, you can use vue-translate outside the template section, you just have to call this.$translate.text("my text") instead. In your example:

$('#error').text(this.$translate.text("error min max"));

Make sure that the this context refers to the Vue instance where you define the locales.

Hey, sorry for the looong delay 😅 but yeah @tobias-grasse is right! you can use it in your script part of the component. Please let us know if you have more questions, thanks.