Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Using i18n#3939

Unanswered
AndresDiazG asked this question inQ&A
Mar 10, 2022· 1 comment
Discussion options

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.

You must be logged in to vote

Replies: 1 comment

Comment options

Hi

In order to use i18n, you need to add translations in the language files in this dir/src/lang/.
For example:
If I have these translations setup.

//en.js English translationexportdefault{response:{accept:'yes',deny:'no',doubt:'maybe'}}
//es.js Spanish translationexportdefault{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>exportdefault {mounted() {console.log(this.$t('response.accept'))    }  }</script>

Make sure to have i18n imported in the index.js file

importi18nfrom'./lang'

In a js file, I can access it by:

importi18nfrom'~/lang'constaccept=i18n.t('response.accept')exportdefaultaccept
You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@AndresDiazG@markhermano

[8]ページ先頭

©2009-2025 Movatter.jp