How to use $t in a .js file?
See original GitHub issueI have a filter.js file in which I store my Vue filters. I now need to translate some of the content, so basically I want to do something like this:
File: filters.js
import Vue from 'vue'
Vue.filter('my-filter', value => {
return `${value} ${$t('my-key')}`
});
Is it possible?
<div align="right">This question is available on Nuxt.js community (#c79)</div>Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:15
Top Results From Across the Web
How to use $t in a .js file? · Issue #84 · nuxt-modules/i18n
I have a filter.js file in which I store my Vue filters. I now need to translate some of the content, ... Just...
Read more >How to get i18next.t() in plain JS file? - Stack Overflow
You can import i18n instance from your i18n.js file, it contains t on it. import i18n from '../i18n'; i18n.t // <- use it....
Read more >Including JavaScript In Your Page
To include an external JavaScript file, we can use the script tag with the attribute src . You've already used the src attribute...
Read more >Documentation - Type Checking JavaScript Files - TypeScript
In a .js file, the compiler infers properties from property assignments inside the class body. The type of a property is the type...
Read more >Why won't .js files work in notepad++ - Codecademy
I have an html and a css file along with a script.js file all in the same folder. the html and css work...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can try this
export const $t = sign => Vue.prototype.$nuxt.$options.i18n.t(sign);
An easy way to use in a completely separated JS file: