fix(i18n): localize factory AI prompt seeds in Japanese
Japanese UI was falling back to English seed copy only because the catalog had no ja translations. Add Japanese names, descriptions, and instructions, and resolve ja the same way as zh-CN and en-US.
This commit is contained in:
1 parent
ea9900b7e2
commit
98dca9baf2
2 files changed
+52
-6
No files matched your search
@@ -460,6 +460,16 @@ describe("AI prompt template routes", () => {
|
||||
description: "压缩全文,提炼主题、结论与可执行结果",
|
||||
instruction: "Only this instruction was customized before the metadata migration.",
|
||||
});
|
||||
|
||||
const japanese = await app.request("/api/v1/ai/prompts?locale=ja", {}, environment);
|
||||
const japaneseSummary = (await japanese.json()).prompts.find(
|
||||
(prompt) => prompt.seedKey === "summarize",
|
||||
);
|
||||
expect(japaneseSummary).toMatchObject({
|
||||
name: "要約する",
|
||||
description: "テーマ、結論、実行できる結果に圧縮する",
|
||||
instruction: "Only this instruction was customized before the metadata migration.",
|
||||
});
|
||||
});
|
||||
|
||||
test("restores prompt behavior from backup without overwriting factory identity", async () => {
|
||||
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
import { resolveSupportedLocale } from "./i18n/locales";
|
||||
|
||||
export type AiPromptSeedKey = Exclude<AiAction, "custom">;
|
||||
export type AiPromptSeedLocale = "zh-CN" | "en-US";
|
||||
export type AiPromptSeedLocale = "zh-CN" | "en-US" | "ja";
|
||||
|
||||
export type AiPromptSeedTranslation = {
|
||||
name: string;
|
||||
@@ -27,16 +27,15 @@ const seed = (
|
||||
metadata: Omit<AiPromptSeed, keyof AiPromptSeedTranslation | "translations">,
|
||||
zhCN: AiPromptSeedTranslation,
|
||||
enUS: AiPromptSeedTranslation,
|
||||
ja: AiPromptSeedTranslation,
|
||||
): AiPromptSeed => ({
|
||||
...metadata,
|
||||
...zhCN,
|
||||
translations: { "zh-CN": zhCN, "en-US": enUS },
|
||||
translations: { "zh-CN": zhCN, "en-US": enUS, ja },
|
||||
});
|
||||
|
||||
export const normalizeAiPromptSeedLocale = (locale: string | null | undefined): AiPromptSeedLocale => {
|
||||
const resolved = resolveSupportedLocale(locale);
|
||||
return resolved === "zh-CN" ? "zh-CN" : "en-US";
|
||||
};
|
||||
export const normalizeAiPromptSeedLocale = (locale: string | null | undefined): AiPromptSeedLocale =>
|
||||
resolveSupportedLocale(locale);
|
||||
|
||||
export const localizeAiPromptSeed = (
|
||||
promptSeed: AiPromptSeed,
|
||||
@@ -86,6 +85,18 @@ export const DEFAULT_AI_PROMPT_SEEDS: readonly AiPromptSeed[] = [
|
||||
"Preserve the note's language and return only the summary in Markdown.",
|
||||
].join(""),
|
||||
},
|
||||
{
|
||||
name: "要約する",
|
||||
description: "テーマ、結論、実行できる結果に圧縮する",
|
||||
instruction: [
|
||||
"ノートを本当に要約してください。逐語の言い換え、行ごとの書き換え、エコーのような再述はしないでください。",
|
||||
"中心テーマ、主要な主張、重要な結論、実行できる結果を抜き出してください。",
|
||||
"繰り返し、修辞、例示、引用、枝葉の詳細は、重要な結論を理解するのに必要でない限り省いてください。",
|
||||
"長いノートは原文のおよそ 20–30% を目安に、3–7 個の簡潔な Markdown 箇条書きにしてください。短いノートは 1–3 文で構いません。",
|
||||
"長い原文をそのまま写したり、原文にない事実を足したりしないでください。",
|
||||
"ノートの言語を保ち、Markdown の要約だけを返してください。",
|
||||
].join(""),
|
||||
},
|
||||
),
|
||||
seed(
|
||||
{ key: "translate", action: "translate", parameterKind: "target-language", resultMode: "both" },
|
||||
@@ -99,6 +110,11 @@ export const DEFAULT_AI_PROMPT_SEEDS: readonly AiPromptSeed[] = [
|
||||
description: "Translate into a selected language while preserving formatting",
|
||||
instruction: "Translate the complete note into the target language specified by the user. Preserve its meaning, Markdown structure, links, and code blocks. Return only the translated note without commentary.",
|
||||
},
|
||||
{
|
||||
name: "翻訳する",
|
||||
description: "指定した言語へ翻訳し、構造と書式を残す",
|
||||
instruction: "ノート全体を、ユーザーが指定した目標言語へ翻訳してください。意味、Markdown の構造、リンク、コードブロックは残してください。解説は付けず、訳文だけを返してください。",
|
||||
},
|
||||
),
|
||||
seed(
|
||||
{ key: "improve-writing", action: "improve-writing", parameterKind: "none", resultMode: "both" },
|
||||
@@ -112,6 +128,11 @@ export const DEFAULT_AI_PROMPT_SEEDS: readonly AiPromptSeed[] = [
|
||||
description: "Correct the language and improve clarity and flow",
|
||||
instruction: "Polish the content by correcting spelling, grammar, and punctuation and improving word choice, sentence structure, clarity, and flow. Do not change its meaning or deliberately shorten it. Preserve its language and useful Markdown formatting. Return only the polished content.",
|
||||
},
|
||||
{
|
||||
name: "文章を整える",
|
||||
description: "誤字と文法を直し、わかりやすさと流れを上げる",
|
||||
instruction: "内容を整えてください。誤字、文法、句読点を直し、語彙、文の形、明瞭さ、流れを改善します。意味を変えたり、意図的に短くしたりしないでください。元の言語と有用な Markdown 書式は残してください。整えた本文だけを返してください。",
|
||||
},
|
||||
),
|
||||
seed(
|
||||
{ key: "make-shorter", action: "make-shorter", parameterKind: "none", resultMode: "both" },
|
||||
@@ -125,6 +146,11 @@ export const DEFAULT_AI_PROMPT_SEEDS: readonly AiPromptSeed[] = [
|
||||
description: "Remove repetition and make the writing concise and direct",
|
||||
instruction: "Refine the content by removing repetition, filler, and unnecessary modifiers and by combining sentences where useful. Make it concise, clear, and direct while preserving every key fact, claim, and the original meaning. Do not add new information. Preserve its language and useful Markdown formatting. Return only the refined content.",
|
||||
},
|
||||
{
|
||||
name: "簡潔にする",
|
||||
description: "重複と冗長さを削り、短くはっきり書く",
|
||||
instruction: "内容を簡潔にしてください。繰り返し、空疎な言い回し、不要な修飾を削り、まとめられる文はまとめて、短く、はっきり、力強くしてください。重要な事実、主張、元の意味はすべて残し、新しい情報は足さないでください。元の言語と有用な Markdown 書式は残してください。簡潔にした本文だけを返してください。",
|
||||
},
|
||||
),
|
||||
seed(
|
||||
{ key: "extract-todos", action: "extract-todos", parameterKind: "none", resultMode: "append" },
|
||||
@@ -138,6 +164,11 @@ export const DEFAULT_AI_PROMPT_SEEDS: readonly AiPromptSeed[] = [
|
||||
description: "Identify actionable work and produce a task list",
|
||||
instruction: "Extract explicit or implied actionable tasks from the note as a Markdown task list using '- [ ]'. Preserve its language and do not invent tasks. If there are no actionable tasks, say so briefly in the note's language.",
|
||||
},
|
||||
{
|
||||
name: "タスクを抜き出す",
|
||||
description: "実行できる作業を見つけ、チェックリストにする",
|
||||
instruction: "ノートから明示または含意された実行可能なタスクを抜き出し、Markdown のタスクリスト(- [ ])で出力してください。ノートの言語を保ち、タスクを捏造しないでください。実行できることがなければ、ノートの言語で短くそう書いてください。",
|
||||
},
|
||||
),
|
||||
seed(
|
||||
{ key: "continue-writing", action: "continue-writing", parameterKind: "none", resultMode: "append" },
|
||||
@@ -151,6 +182,11 @@ export const DEFAULT_AI_PROMPT_SEEDS: readonly AiPromptSeed[] = [
|
||||
description: "Continue naturally from the end of the note",
|
||||
instruction: "Continue writing naturally from where the note ends. Return only the new continuation, not the original content. Preserve its language and Markdown style.",
|
||||
},
|
||||
{
|
||||
name: "続きを書く",
|
||||
description: "ノートの末尾から自然に書き継ぐ",
|
||||
instruction: "ノートの終わりから自然に書き継いでください。原文は繰り返さず、新しい続きだけを返してください。元の言語と Markdown の調子を保ってください。",
|
||||
},
|
||||
),
|
||||
];
|
||||
|
||||
|
||||
Reference in new issue
Block a user