hex-lowcode-engine 全面支持国际化咯~
hex-lowcode-engine 目前的默认文案是英文,如果需要使用其他语言,可以参考下面的方案。
目前支持以下语言:
| 语言 | 文件名 |
|---|---|
| 英语 | en |
| 简体中文 | zh-CN |
产品不断更新中,欢迎使用和反馈!!!
配置方式
- Props
// 编译器
<hex-lowcode-engine-compiler :config="{ i18n: 'zh-CN' }" />
// 渲染器
<hex-lowcode-engine-renderer :config="{ i18n: 'zh-CN' }" />
实现方案
通过 vue的 provide 和 inject 去实现国际化功能。
部分代码:
export const useLocale = (localeOverrides?: Ref<Language | undefined>) => {
const locale = localeOverrides || inject(localeContextKey, ref())!;
return buildLocaleContext(computed(() => locale.value || English));
};