[Vuejs]-Getting the translated string inside the script โ€“ Vue JS + Vue Translate

0๐Ÿ‘

You can directly use Vue external functions like you did. Here is a short working example:

new Vue({
  el: '#content',
  data: {
    text: t('hello_world')
  }
})

function t(text) {
  return 'Hello World' // simulate output for demonstration purposes
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.min.js"></script>
<div id="content">
  {{ text }}
</div>

0๐Ÿ‘

I think you should use Vue-i18n, it can solve you problem.

Leave a comment