-
-
Notifications
You must be signed in to change notification settings - Fork 861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use $t function outside template #17
Comments
It works with |
How can I use $t outside of a Vue component, for example in a service class which retrieves data from an API and sets strings? Another example is how could I also use it in my main init file where I set global things such as custom validator messages as below:
How could I use $t to translate the message above? Thanks |
arronjpitts question is still valid, how do i translate text in components? and why is this closed? |
Seconded |
You can access translator globally like this: import Vue from 'vue'
Vue.t('your.translation') |
I cannot use the |
I figured it out like this comment at issue #149 |
This approach works for me like a charm - I use this statement inside a store action:
Found in the Vue forum here: https://forum.vuejs.org/t/how-to-use-t-from-vue-i18n-inside-vuex-action/22146/3 |
Hi,
I'm trying to do simple
alert( $t('error') )
in my JavaScript file but $t is undefined.I've also tried
Vue.$t
but it is also undefined.Is there any way to use the $t function outside a template ?
Thank you,
clem.
The text was updated successfully, but these errors were encountered: