mar*_*ube 2 localization vue-component nuxt.js vue-i18n nuxt-i18n
我正在尝试使用 nuxt-I18n 模块进行本地化。我已经安装"nuxt-i18n": "^6.4.1"
同样在我的 nuxt.config.js 我有休耕
modules: [
[
'nuxt-i18n',
{
defaultLocale: 'en',
lazy: true,
langDir: 'locales/',
locales: [
{
code: 'mk',
name: '??????????',
file: 'mk.js',
},
{
code: 'en',
name: 'English',
file: 'en.js',
},
],
},
],
],
Run Code Online (Sandbox Code Playgroud)
我还创建了文件夹语言环境,其中有 2 个文件,我在其中编写本地化。我项目中的大部分文本都很简单,所以我在这个设置上做得很好。但是我最终遇到了问题。我有一个文本段落,里面有一个链接,内容如下:
<p>Lorem ipsum <a href="#"> This is link </a> dolor sit amet. </p>
Run Code Online (Sandbox Code Playgroud)
我试图用 i18n 的组件来解决这个问题,但我有很多错误。
谁能给我一个如何解决这个问题的例子?
我解决了我的问题,所以如果有人面临同样的问题,我希望将其分享。为了更好地理解,您可以阅读有关组件插值的休闲链接。
<i18n path="text" tag="p">
<template v-slot:link>
<a>{{ $t('link') }}</a>
</template>
</i18n
Run Code Online (Sandbox Code Playgroud)
我的语言环境看起来像:
en: {
text: 'You can check {link} for more details.',
link: 'component interpolation',
Run Code Online (Sandbox Code Playgroud)
}
| 归档时间: |
|
| 查看次数: |
1147 次 |
| 最近记录: |