Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat(i18n): localize auth and notification emails for Japanese

sinskycf4ea8f4ddbd
diff --git a/apps/api/src/auth.ts b/apps/api/src/auth.ts
index 9c5120385..651b00b29 100644
--- a/apps/api/src/auth.ts
+++ b/apps/api/src/auth.ts
@@ -122,6 +122,7 @@ function getLocaleKey(locale?: string | null) {
const normalized = locale?.toLowerCase();
if (normalized?.startsWith("de")) return "de";
if (normalized?.startsWith("vi")) return "vi";
+ if (normalized?.startsWith("ja")) return "ja";
return "en";
}
@@ -142,6 +143,13 @@ function getAuthEmailCopy(locale?: string | null) {
};
}
+ if (localeKey === "ja") {
+ return {
+ magicLinkSubject: "Kaneo ログインリンク",
+ otpSubject: "Kaneo 認証コード",
+ };
+ }
+
return {
magicLinkSubject: "Login for Kaneo",
otpSubject: "Authentication code for Kaneo",
diff --git a/apps/api/src/utils/get-workspace-invitation-email-copy.ts b/apps/api/src/utils/get-workspace-invitation-email-copy.ts
index 172818e3f..40de65198 100644
--- a/apps/api/src/utils/get-workspace-invitation-email-copy.ts
+++ b/apps/api/src/utils/get-workspace-invitation-email-copy.ts
@@ -1,6 +1,7 @@
import deDE from "../../../../i18n/de-DE.json";
import enUS from "../../../../i18n/en-US.json";
import frFR from "../../../../i18n/fr-FR.json";
+import jaJP from "../../../../i18n/ja-JP.json";
import ptBR from "../../../../i18n/pt-BR.json";
import viVN from "../../../../i18n/vi-VN.json";
@@ -8,6 +9,7 @@ const messages = {
de: deDE.invitations.email,
en: enUS.invitations.email,
fr: frFR.invitations.email,
+ ja: jaJP.invitations.email,
pt: ptBR.invitations.email,
vi: viVN.invitations.email,
} as const;
@@ -17,6 +19,7 @@ export function getWorkspaceInvitationEmailCopy(locale?: string | null) {
if (normalizedLocale?.startsWith("de")) return messages.de;
if (normalizedLocale?.startsWith("fr")) return messages.fr;
+ if (normalizedLocale?.startsWith("ja")) return messages.ja;
if (normalizedLocale?.startsWith("pt")) return messages.pt;
if (normalizedLocale?.startsWith("vi")) return messages.vi;
diff --git a/packages/email/src/templates/magic-link.test.ts b/packages/email/src/templates/magic-link.test.ts
new file mode 100644
index 000000000..8cf957114
--- /dev/null
+++ b/packages/email/src/templates/magic-link.test.ts
@@ -0,0 +1,17 @@
+import { render } from "@react-email/render";
+import { createElement } from "react";
+import { describe, expect, it } from "vitest";
+import MagicLinkEmail from "./magic-link";
+
+describe("MagicLinkEmail", () => {
+ it("renders Japanese copy for a Japanese locale", async () => {
+ const html = await render(
+ createElement(MagicLinkEmail, {
+ magicLink: "https://kaneo.example/auth",
+ locale: "ja-JP",
+ }),
+ );
+ expect(html).toContain("Kaneo にサインイン");
+ expect(html).toContain("Kaneo セキュリティメール");
+ });
+});
diff --git a/packages/email/src/templates/magic-link.tsx b/packages/email/src/templates/magic-link.tsx
index 37336ea07..6bb2d1089 100644
--- a/packages/email/src/templates/magic-link.tsx
+++ b/packages/email/src/templates/magic-link.tsx
@@ -40,6 +40,15 @@ const messages = {
ignore: "Nếu bạn không yêu cầu điều này, bạn có thể bỏ qua email này.",
footer: "Email bảo mật Kaneo",
},
+ ja: {
+ preview: "Kaneo にサインイン",
+ title: "安全なサインインリンク",
+ subtitle: "このリンクから Kaneo ワークスペースにアクセスできます。",
+ cta: "Kaneo にサインイン",
+ expiry: "セキュリティのため、このリンクは5分で有効期限が切れます。",
+ ignore: "心当たりがない場合は、このメールを無視してかまいません。",
+ footer: "Kaneo セキュリティメール",
+ },
} as const;
const MagicLinkEmail = ({ magicLink, locale }: MagicLinkEmailProps) => {
diff --git a/packages/email/src/templates/notification.test.ts b/packages/email/src/templates/notification.test.ts
new file mode 100644
index 000000000..02ccea6a8
--- /dev/null
+++ b/packages/email/src/templates/notification.test.ts
@@ -0,0 +1,19 @@
+import { render } from "@react-email/render";
+import { createElement } from "react";
+import { describe, expect, it } from "vitest";
+import NotificationEmail from "./notification";
+
+describe("NotificationEmail", () => {
+ it("renders Japanese chrome for a Japanese locale", async () => {
+ const html = await render(
+ createElement(NotificationEmail, {
+ title: "タスクが割り当てられました",
+ message: "デザイン案の確認をお願いします。",
+ actionUrl: "https://kaneo.example/task/1",
+ locale: "ja-JP",
+ }),
+ );
+ expect(html).toContain("Kaneo で開く");
+ expect(html).toContain("配信設定に一致する通知がありました。");
+ });
+});
diff --git a/packages/email/src/templates/notification.tsx b/packages/email/src/templates/notification.tsx
index 4226f476a..541023087 100644
--- a/packages/email/src/templates/notification.tsx
+++ b/packages/email/src/templates/notification.tsx
@@ -33,6 +33,12 @@ const messages = {
footer: "Thông báo Kaneo",
actionLabel: "Mở trong Kaneo",
},
+ ja: {
+ preview: "Kaneo の新しい通知",
+ subtitle: "配信設定に一致する通知がありました。",
+ footer: "Kaneo 通知",
+ actionLabel: "Kaneo で開く",
+ },
} as const;
const NotificationEmail = ({
diff --git a/packages/email/src/templates/otp.test.ts b/packages/email/src/templates/otp.test.ts
index 880821782..1fcb72531 100644
--- a/packages/email/src/templates/otp.test.ts
+++ b/packages/email/src/templates/otp.test.ts
@@ -9,4 +9,12 @@ describe("OtpEmail", () => {
expect(html).toContain("123456");
expect(html).toContain("verification code");
});
+
+ it("renders Japanese copy for a Japanese locale", async () => {
+ const html = await render(
+ createElement(OtpEmail, { otp: "123456", locale: "ja-JP" }),
+ );
+ expect(html).toContain("確認コード");
+ expect(html).toContain("Kaneo セキュリティメール");
+ });
});
diff --git a/packages/email/src/templates/otp.tsx b/packages/email/src/templates/otp.tsx
index 0c598155e..cec02a1b8 100644
--- a/packages/email/src/templates/otp.tsx
+++ b/packages/email/src/templates/otp.tsx
@@ -39,6 +39,16 @@ const messages = {
ignore: "Nếu bạn không yêu cầu điều này, bạn có thể bỏ qua email này.",
footer: "Email bảo mật Kaneo",
},
+ ja: {
+ preview: "Kaneo の確認コード",
+ title: "確認コード",
+ subtitle:
+ "サインインを完了するには、このワンタイムコードを入力してください。",
+ code: "はあなたの Kaneo 確認コードです。",
+ expiry: "このコードの有効期限は15分です。",
+ ignore: "心当たりがない場合は、このメールを無視してかまいません。",
+ footer: "Kaneo セキュリティメール",
+ },
} as const;
const OtpEmail = ({ otp, locale }: OtpEmailProps) => {
diff --git a/packages/email/src/templates/password-reset.test.ts b/packages/email/src/templates/password-reset.test.ts
new file mode 100644
index 000000000..c80ea1fa9
--- /dev/null
+++ b/packages/email/src/templates/password-reset.test.ts
@@ -0,0 +1,17 @@
+import { render } from "@react-email/render";
+import { createElement } from "react";
+import { describe, expect, it } from "vitest";
+import PasswordResetEmail from "./password-reset";
+
+describe("PasswordResetEmail", () => {
+ it("renders Japanese copy for a Japanese locale", async () => {
+ const html = await render(
+ createElement(PasswordResetEmail, {
+ resetLink: "https://kaneo.example/reset",
+ locale: "ja-JP",
+ }),
+ );
+ expect(html).toContain("パスワードのリセット");
+ expect(html).toContain("Kaneo セキュリティメール");
+ });
+});
diff --git a/packages/email/src/templates/password-reset.tsx b/packages/email/src/templates/password-reset.tsx
index b2f2e3c4d..d9a40654c 100644
--- a/packages/email/src/templates/password-reset.tsx
+++ b/packages/email/src/templates/password-reset.tsx
@@ -48,6 +48,17 @@ const messages = {
"Nếu bạn không yêu cầu điều này, sẽ không có thay đổi nào được thực hiện.",
footer: "Email bảo mật Kaneo",
},
+ ja: {
+ preview: "Kaneo のパスワードをリセット",
+ title: "パスワードのリセット",
+ subtitleWithName: (name: string) =>
+ `${name} さん、下のボタンから新しいパスワードを設定してください。`,
+ subtitleDefault: "下のボタンから新しいパスワードを設定してください。",
+ cta: "パスワードをリセット",
+ expiry: "このリンクの有効期限は1時間です。",
+ ignore: "心当たりがない場合は、変更は行われません。",
+ footer: "Kaneo セキュリティメール",
+ },
} as const;
const PasswordResetEmail = ({
diff --git a/packages/email/src/templates/resolve-locale.ts b/packages/email/src/templates/resolve-locale.ts
index d7749e791..01b1239e6 100644
--- a/packages/email/src/templates/resolve-locale.ts
+++ b/packages/email/src/templates/resolve-locale.ts
@@ -1,4 +1,4 @@
-const supportedLocales = ["en", "de", "vi"] as const;
+const supportedLocales = ["en", "de", "vi", "ja"] as const;
type EmailLocale = (typeof supportedLocales)[number];
diff --git a/packages/email/src/templates/workspace-invitation.test.ts b/packages/email/src/templates/workspace-invitation.test.ts
index 9b2b33835..371dfc3cb 100644
--- a/packages/email/src/templates/workspace-invitation.test.ts
+++ b/packages/email/src/templates/workspace-invitation.test.ts
@@ -3,6 +3,7 @@ import { createElement } from "react";
import { describe, expect, it } from "vitest";
import enUS from "../../../../i18n/en-US.json";
import frFR from "../../../../i18n/fr-FR.json";
+import jaJP from "../../../../i18n/ja-JP.json";
import WorkspaceInvitationEmail from "./workspace-invitation";
describe("WorkspaceInvitationEmail", () => {
@@ -22,6 +23,23 @@ describe("WorkspaceInvitationEmail", () => {
expect(html).toContain("Accepter l’invitation");
expect(html).toContain("Camille ([email protected])");
});
+
+ it("renders the invitation in Japanese for a Japanese locale", async () => {
+ const html = await render(
+ createElement(WorkspaceInvitationEmail, {
+ workspaceName: "プロダクト",
+ inviterName: "アリス",
+ inviterEmail: "[email protected]",
+ invitationLink: "https://kaneo.example/invite/abc",
+ copy: jaJP.invitations.email,
+ }),
+ );
+
+ expect(html).toContain("「プロダクト」に参加");
+ expect(html).toContain("招待を承諾");
+ expect(html).toContain("アリス ([email protected])");
+ });
});
describe("WorkspaceInvitationEmail default copy", () => {
diff --git a/tests/api/utils/get-invitation-email-subject.test.ts b/tests/api/utils/get-invitation-email-subject.test.ts
index c7904707d..75b4fe0cc 100644
--- a/tests/api/utils/get-invitation-email-subject.test.ts
+++ b/tests/api/utils/get-invitation-email-subject.test.ts
@@ -50,6 +50,22 @@ describe("getInvitationEmailSubject", () => {
);
});
+ it("uses Japanese copy for Japanese locales", () => {
+ const locale = "ja-JP";
+ const inviterName = "Alice";
+ const workspaceName = "プロダクト";
+
+ const subject = getInvitationEmailSubject(
+ locale,
+ inviterName,
+ workspaceName,
+ );
+
+ expect(subject).toBe(
+ "Alice さんが Kaneo の「プロダクト」にあなたを招待しました",
+ );
+ });
+
it("uses the English fallback for unsupported locales", () => {
const locale = "es-ES";
const inviterName = "Alice";