From 395a2dbfa708b82b2728b6d77919701eb39ec67c Mon Sep 17 00:00:00 2001 From: Handa Date: Mon, 19 Aug 2024 15:19:06 +0800 Subject: [PATCH] Optimize translation prompts --- packages/lobe-i18n/examples/locale/flat/locales/en_US.json | 1 + packages/lobe-i18n/examples/locale/flat/locales/ja_JP.json | 5 +++-- packages/lobe-i18n/examples/locale/flat/locales/zh_CN.json | 5 +++-- packages/lobe-i18n/src/prompts/translate.ts | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/lobe-i18n/examples/locale/flat/locales/en_US.json b/packages/lobe-i18n/examples/locale/flat/locales/en_US.json index c9bc0fc..7813fe7 100644 --- a/packages/lobe-i18n/examples/locale/flat/locales/en_US.json +++ b/packages/lobe-i18n/examples/locale/flat/locales/en_US.json @@ -3,5 +3,6 @@ "ok": "Ok", "cancel": "Cancel" }, + "list": ["How are you", "I'm fine."], "welcome": "Welcome!" } diff --git a/packages/lobe-i18n/examples/locale/flat/locales/ja_JP.json b/packages/lobe-i18n/examples/locale/flat/locales/ja_JP.json index 28c45b8..02bd3b9 100644 --- a/packages/lobe-i18n/examples/locale/flat/locales/ja_JP.json +++ b/packages/lobe-i18n/examples/locale/flat/locales/ja_JP.json @@ -1,7 +1,8 @@ { "buttons": { - "ok": "OK", - "cancel": "キャンセル" + "cancel": "キャンセル", + "ok": "はい" }, + "list": ["お元気ですか", "私は元気です。"], "welcome": "ようこそ!" } diff --git a/packages/lobe-i18n/examples/locale/flat/locales/zh_CN.json b/packages/lobe-i18n/examples/locale/flat/locales/zh_CN.json index 6f09210..bd1317f 100644 --- a/packages/lobe-i18n/examples/locale/flat/locales/zh_CN.json +++ b/packages/lobe-i18n/examples/locale/flat/locales/zh_CN.json @@ -1,7 +1,8 @@ { "buttons": { - "ok": "Ok", - "cancel": "Cancel" + "cancel": "取消", + "ok": "好的" }, + "list": ["你好吗", "我很好。"], "welcome": "欢迎!" } diff --git a/packages/lobe-i18n/src/prompts/translate.ts b/packages/lobe-i18n/src/prompts/translate.ts index 8d60375..98275c8 100644 --- a/packages/lobe-i18n/src/prompts/translate.ts +++ b/packages/lobe-i18n/src/prompts/translate.ts @@ -14,6 +14,7 @@ export const promptJsonTranslate = (reference: string = DEFAULT_REFERENCE) => { `Translate the i18n JSON file from {from} to {to} according to the BCP 47 standard`, `Here are some reference to help with better translation. ---${reference}---`, `Keep the keys the same as the original file and make sure the output remains a valid i18n JSON file.`, + `Do not include any additional text or explanations outside the JSON object.Start directly with a left brace and end with a right brace.`, ] .filter(Boolean) .join('\n'),