@@ -161,6 +184,21 @@ function ExtensionResult({
{result.message}
) : null}
{body ? {body}
: null}
+ {translation.translation ? (
+
+ {translation.translation}
+
+ ) : null}
+ {translation.note ? (
+ {translation.note}
+ ) : null}
+ {translation.alternatives.length ? (
+
+ {translation.alternatives.map((alternative, index) => (
+ - {alternative}
+ ))}
+
+ ) : null}
{items.length ? (
{items.map((item) => (
diff --git a/web/locales/en/app.json b/web/locales/en/app.json
index 300b8d93c..eb65e318f 100644
--- a/web/locales/en/app.json
+++ b/web/locales/en/app.json
@@ -434,6 +434,7 @@
"View": "View",
"Close": "Close",
"No speech voice is available in this browser.": "No speech voice is available in this browser.",
+ "Translate selection": "Translate selection",
"messages": "messages",
"Failed to load session": "Failed to load session",
"Added Successfully!": "Added Successfully!",
diff --git a/web/locales/zh/app.json b/web/locales/zh/app.json
index 85b1d8031..69c477ae1 100644
--- a/web/locales/zh/app.json
+++ b/web/locales/zh/app.json
@@ -434,6 +434,7 @@
"View": "查看",
"Close": "关闭",
"No speech voice is available in this browser.": "此浏览器没有可用的语音。",
+ "Translate selection": "翻译选段",
"messages": "条消息",
"Failed to load session": "加载会话失败",
"Added Successfully!": "保存成功!",
diff --git a/web/tests/reading-extensions.test.ts b/web/tests/reading-extensions.test.ts
index a42619f7b..aec85b61a 100644
--- a/web/tests/reading-extensions.test.ts
+++ b/web/tests/reading-extensions.test.ts
@@ -38,3 +38,29 @@ test("a malformed extension catalog cannot crash the whole reader", () => {
/Array\.isArray\(\(row as ReadingExtensionManifest\)\.actions\)/,
);
});
+
+test("the built-in translation action is localized", () => {
+ assert.match(
+ component,
+ /extensionId === "translation" && actionId === "translate"/,
+ );
+ const english = readFileSync(
+ path.resolve(process.cwd(), "locales/en/app.json"),
+ "utf8",
+ );
+ const chinese = readFileSync(
+ path.resolve(process.cwd(), "locales/zh/app.json"),
+ "utf8",
+ );
+ assert.match(english, /"Translate selection": "Translate selection"/);
+ assert.match(chinese, /"Translate selection": "翻译选段"/);
+});
+
+test("translation results are rendered as text in the result card", () => {
+ assert.match(component, /String\(result\.payload\.translation \|\| ""\)/);
+ assert.match(component, /result\.payload\.alternatives/);
+ assert.match(component, /String\(result\.payload\.note \|\| ""\)/);
+ assert.match(component, /\{translation\.translation\}/);
+ assert.match(component, /\{translation\.note\}/);
+ assert.match(component, /translation\.alternatives\.map/);
+});