Using i18n #3939
Unanswered
AndresDiazG
asked this question in
Q&A
Using i18n
#3939
Replies: 1 comment
-
Hi In order to use i18n, you need to add translations in the language files in this dir //en.js English translation
export default {
response: {
accept: 'yes',
deny: 'no',
doubt: 'maybe'
}
} //es.js Spanish translation
export default {
response: {
accept: 'sí',
deny: 'no',
doubt: 'quizás'
}
} then I can access them in vue template by: <template>
<div>
<ul>
<li>{{ $t('response.accept') }}</li>
<li>{{ $t('response.deny') }}</li>
<li>{{ $t('response.doubt') }}</li>
</ul>
</div>
</template>
<script>
export default {
mounted() {
console.log(this.$t('response.accept'))
}
}
</script> Make sure to have i18n imported in the index.js file import i18n from './lang' In a js file, I can access it by: import i18n from '~/lang'
const accept = i18n.t('response.accept')
export default accept |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
May I ask how to use the i18n component we all see on the demo project? I liked the view and I can see a lot of uses of it in my website but I can't find it on the Master branch or in any other branch this project has.
Thanks
AD.
Beta Was this translation helpful? Give feedback.
All reactions