-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
i18n related issue | 国际化相关问题 #2610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
作者你好,请问在 ts 中复制官方的代码,无法找到对应的 类型文件,有什么解决的吗,如果变为 js 文件,也需要 |
这个问题我刚发现,我们之前发布的版本都是有 |
@Pmj136 https://element-plus.org/#/zh-CN/component/i18n 有缓存,你强刷一下,我们周末改了东西。 |
作者你好,“通过 CDN 的方式加载语言文件” 似乎失效了,按照文档设置后,依然是英文。
|
@wanghai1 226668d#diff-3d64996115d0ac3b74e36f57ce6b00d6b4982614c41b1ed39eab8ef43b2e9a2b see here for more information, I've updated the build script and triggered a new release. |
|
@panchenyu0928 这好像确实是个问题,你用了 vite 的插件还是 webpack 的插件?可能我们需要加一个空的文件进去,因为这个组件是一个纯功能性组件,我得改一下。 import ConfigProvider from 'element-plus/config-provider' ========================== 应该是 import { ElConfigProvider } from 'element-plus' 我们文档疏忽了 |
@JeremyWuuuuu webpack |
@panchenyu0928 Upgrade to |
@wanghai1 Upgrade to beta.62 see if you still have the same problem. Sorry for the inconvenience that I caused. 🙏 |
在 “通过 CDN 的方式加载语言文件” 这个语境下: 旧版只需要 ElementPlus.locale(ElementPlus.lang.zhCn) 一下,全局就是中文的了。 而 1.0.2-beta.59(以及之后的版本),ElementPlus.locale 已经失效。 像下面这样:
|
vite 2.3.0 按需引入i18n,页面不起效果
而且升级到最新版本后 分页功能不支持直接导入 css 样式,只能导入 scss 样式
|
你好,目前63版本使用 |
版本1.0.2-beta.63 默认设置中文无效,这问题怎么解决 |
作者你好通过按需加载,单纯设置中文应该怎么设置。文档中写的也不是很详细。1.0.2-beta.54这个版本设置中文也失效了 |
作者你好,兼容vue-i18n@9.x使用国际化时 |
是的,但你也可以用 |
|
1.1.0-beta.5 config-provider + i18n 这里的locale貌似只能是翻译文本对象。暂用$i18n.messages[$i18n.locale]取得对应的文本 APP.vue
封装的 i18n.js
main.js
动态切换语言,在其他地方变更i18n的locale值即可
|
感谢楼上的思路,可以优化下, "element-plus": "1.1.0-beta.7" import { createI18n } from 'vue-i18n';
import enLocale from 'element-plus/es/locale/lang/en';
import zhLocale from 'element-plus/es/locale/lang/zh-cn';
const messages = {
en: {
el: enLocale,
app: {
youLocale
}
},
'zh-cn': {
el: zhLocale,
app: {
youLocale
}
}
};
/**
* 注册i18n实例并引入语言文件
*/
const i18n = createI18n({
// 默认语言,存入localStorage
locale: getLocale(),
fallbackLocale: 'zh-cn',
messages
});
export default i18n; <el-config-provider :locale="$i18n.messages[$i18n.locale].el">
....
</el-config-provider> |
一直是英文,用ElConfigProvider是中文 |
This comment has been minimized.
This comment has been minimized.
请问你找到解决方法了吗?这个问题已经困扰我两天了,貌似官方还未修复 |
|
@BelinChung thank you very much, that helped :) |
关于
然后在初始化
|
国际化文档的引用路径应该还没改吧:
|
官方文档都切换不到中文了。。。 |
新的官方文档中文翻译不完整 |
请问在手动导入的情况下,如何为element-plus设置国际化,官方文档只提到了 app.use(elementPlus, { locale: zh_CN } ),但这不是我想要的。我用的打包工具是webpack |
我的element-plus版本是1.1.0-beta19 |
@daiwanxing import { createApp } from "vue";
import ElementPlus from "element-plus";
import cn from "element-plus/es/locale/lang/zh-cn";
import "element-plus/theme-chalk/index.css";
import dayjs from "dayjs";
import "dayjs/locale/zh-cn";
import App from "./App.vue";
dayjs.locale("zh-cn");
createApp(App)
.use(ElementPlus, {
locale: cn
})
.mount("#app"); |
@Zssaer 新文档的中文翻译目前并未完成,需要靠大家一起贡献。 |
@GLFei 请新开一个 issue 阐述这个问题。 |
Since this issue is too long and outdated, so I close it. If there is any bugs, please open a new issue or discussion. |
这种是全局引入的形式,打包后体积增大了许多,请问按需引入时应该怎么写? |
@zmzimpl 请参考最新的官方文档。 |
el-config-provider 的 locale 的值不能使用 computed,例如: const locale = computed(() => {
switch (LocaleService.locale.value) {
case 'en':
return en;
default:
return zhCN;
}
}); <el-config-provider :locale="locale">
...
</el-config-provider> 会提示错误: |
@gzf6 Could you please create a new issue about this problem? |
Hey guys, if you found any i18n related issue please report it here within this issue we will try to fix them ASAP.
Feel free to ping me or the team here to help you out. This should be the top priority of us and we intend to fix most of them by the first stable release. Thank you for being patient and supportive. Your comments could be the key for ElementPlus to become a great project 🙏
大家好,如果你们在项目中发现 ElementPlus 和国际化不太对劲的地方,请在这个 issue 里留言,我们会把国际化 相关的问题作为最高优先级并想办法修复。
非常感谢大家一直以来对 ElementPlus 的支持与耐心,你们的留言会帮助 ElementPlus 成长为一个更好的项目。谢谢!🙏
The text was updated successfully, but these errors were encountered: