How to access translations in static .js file?



  • This post is deleted!


  • @mYnDstrEAm export the instance of your i18n boot.

    something like this:

    //src/boot/i18n.js
    ...
    let i18n = null
    export default ({ app }) => {
      // Set i18n instance on app;
      // We inject it into root component by doing so;
      // new Vue({..., i18n: ... }).$mount(...)
    i18n = new VueI18n({
        locale: 'en',
        fallbackLocale: 'en',
        messages
      })
      app.i18n = i18n
    }
    
    export { i18n }
    
    // some js file
    import { i18n } from 'src/boot/i18n.js'
    ...
    i18n.t('translation.path')
    


  • @mYnDstrEAm you didn’t need to delete your post, just marked the title as [Solved] *if it was solved, for others who might stumble upon the same issue :).


Log in to reply