fix: 修复i18n格式化错误
This commit is contained in:
@@ -15,7 +15,11 @@ const props = defineProps<{
|
|||||||
connectionToEdit: ConnectionInfo | null;
|
connectionToEdit: ConnectionInfo | null;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { t } = useI18n();
|
import { getTranslation } from '../utils/languageUtils';
|
||||||
|
|
||||||
|
|
||||||
|
const { t, locale } = useI18n();
|
||||||
|
const scriptModeFormatInfo = ref(getTranslation('connections.form.scriptModeFormatInfo', locale.value));
|
||||||
|
|
||||||
const {
|
const {
|
||||||
formData,
|
formData,
|
||||||
@@ -143,7 +147,7 @@ const handleHostIconMouseLeave = () => {
|
|||||||
:placeholder="t('connections.form.scriptModePlaceholder')"
|
:placeholder="t('connections.form.scriptModePlaceholder')"
|
||||||
></textarea>
|
></textarea>
|
||||||
<p class="mt-1 text-xs text-text-secondary whitespace-pre-line">
|
<p class="mt-1 text-xs text-text-secondary whitespace-pre-line">
|
||||||
{{ t('connections.form.scriptModeFormatInfo') }}
|
{{ scriptModeFormatInfo }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import zhCN from '../locales/zh-CN.json';
|
||||||
|
import enUS from '../locales/en-US.json';
|
||||||
|
import jaJP from '../locales/ja-JP.json';
|
||||||
|
|
||||||
|
const languages = {
|
||||||
|
'zh-CN': zhCN,
|
||||||
|
'en-US': enUS,
|
||||||
|
'ja-JP': jaJP,
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getTranslation(key: string, locale: string = 'zh-CN'): string {
|
||||||
|
const keys = key.split('.');
|
||||||
|
let current: any = languages[locale as keyof typeof languages] || languages['zh-CN'];
|
||||||
|
|
||||||
|
for (const k of keys) {
|
||||||
|
current = current[k];
|
||||||
|
if (!current) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return current;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user