首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何翻译Quasar组件?

如何翻译Quasar组件?
EN

Stack Overflow用户
提问于 2020-06-11 16:12:09
回答 1查看 653关注 0票数 0

我有一个使用i18n的Vue/Quasar应用程序,但现在我面临一个问题:表页脚不能被翻译。例如,在表头中,我执行以下操作来转换列名:

代码语言:javascript
复制
{
  align: 'left',
  field: (val) => val,
  label: this.$t('locale.column'),
  name: 'column',
  required: true,
  sortable: true,
},

其中$t是18n函数,locale是我的组件,列实际上是列的名称。我不能直接访问表的页脚(分页和元素的总数),它也不会被翻译。我也使用类星体语言包,quasar.js是这样的:

代码语言:javascript
复制
import en from 'quasar/lang/en-us.js'
/*
  import other languages
*/
import {
  state,
} from '@state/modules/i18n';

const locale = state.locale;
const langDictionary = {
  // all the imported langs go here
};

Vue.use(Quasar, {
  config: {},
  components: { /* not needed if importStrategy is not 'manual' */ },
  directives: { /* not needed if importStrategy is not 'manual' */ },
  plugins: {
    Cookies,
    Dialog,
    Loading,
    Notify,
  },
  lang: langDictionary[locale]
});

export {langDictionary}; 
EN

回答 1

Stack Overflow用户

发布于 2020-06-20 20:26:36

您可能在启动时将语言正确设置为lang: langDictionary[locale]。如果您稍后更改了应用程序中的语言状态,您还需要通知Quasar是否希望Quasar组件和插件得到正确翻译。请参阅文档,Change Quasar Language Pack at Runtime了解如何实现这一点,关于语言包的文档还包含了动态加载语言包的提示。

您没有指定如何在您的应用程序中更改语言,所以我不能在此基础上给出一个示例。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62319884

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档