我有一个使用i18n的Vue/Quasar应用程序,但现在我面临一个问题:表页脚不能被翻译。例如,在表头中,我执行以下操作来转换列名:
{
align: 'left',
field: (val) => val,
label: this.$t('locale.column'),
name: 'column',
required: true,
sortable: true,
},其中$t是18n函数,locale是我的组件,列实际上是列的名称。我不能直接访问表的页脚(分页和元素的总数),它也不会被翻译。我也使用类星体语言包,quasar.js是这样的:
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}; 发布于 2020-06-20 20:26:36
您可能在启动时将语言正确设置为lang: langDictionary[locale]。如果您稍后更改了应用程序中的语言状态,您还需要通知Quasar是否希望Quasar组件和插件得到正确翻译。请参阅文档,Change Quasar Language Pack at Runtime了解如何实现这一点,关于语言包的文档还包含了动态加载语言包的提示。
您没有指定如何在您的应用程序中更改语言,所以我不能在此基础上给出一个示例。
https://stackoverflow.com/questions/62319884
复制相似问题