From 74912093a06801d964889e48f91911fb23fa97e2 Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Tue, 14 Feb 2023 18:16:34 +0900 Subject: [PATCH 1/5] Make localization keys on HelpUserSettingsTab compatible with agglutinative and/or SOV type languages Signed-off-by: Suguru Hirahara --- .../tabs/user/HelpUserSettingsTab.tsx | 20 +++++++++++++++++-- src/i18n/strings/en_EN.json | 6 +++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx b/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx index 83b81aa3fdb..da5fc90caba 100644 --- a/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx @@ -327,10 +327,26 @@ export default class HelpUserSettingsTab extends React.Component {_t("Advanced")}
- {_t("Homeserver is")} {MatrixClientPeg.get().getHomeserverUrl()} + {_t( + "Homeserver is %(homeserverUrl)s", + { + homeserverUrl: MatrixClientPeg.get().getHomeserverUrl(), + }, + { + code: (sub) => {sub}, + }, + )}
- {_t("Identity server is")} {MatrixClientPeg.get().getIdentityServerUrl()} + {_t( + "Identity server is %(identityServerUrl)s", + { + identityServerUrl: MatrixClientPeg.get().getIdentityServerUrl(), + }, + { + code: (sub) => {sub}, + }, + )}
{_t("Access Token")} diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8cdb69d5852..7681df7d182 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1574,8 +1574,8 @@ "FAQ": "FAQ", "Keyboard Shortcuts": "Keyboard Shortcuts", "Versions": "Versions", - "Homeserver is": "Homeserver is", - "Identity server is": "Identity server is", + "Homeserver is %(homeserverUrl)s": "Homeserver is %(homeserverUrl)s", + "Identity server is %(identityServerUrl)s": "Identity server is %(identityServerUrl)s", "Access Token": "Access Token", "Your access token gives full access to your account. Do not share it with anyone.": "Your access token gives full access to your account. Do not share it with anyone.", "Clear cache and reload": "Clear cache and reload", @@ -3156,7 +3156,7 @@ "Room status": "Room status", "Room unread status: ": "Room unread status: ", ", count:": ", count:", - "Notification state is": "Notification state is", + "Notification state is %(notificationState)s": "Notification state is %(notificationState)s", "Room is ": "Room is ", "encrypted ✅": "encrypted ✅", "not encrypted 🚨": "not encrypted 🚨", From 13bdebe4875946cc4cee96f8244f8eff1af6fbac Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Tue, 14 Feb 2023 18:23:26 +0900 Subject: [PATCH 2/5] Make localization keys on room notifications debug dialog on devtools compatible with agglutinative and/or SOV type languages Make keys compatible with inflection Signed-off-by: Suguru Hirahara --- .../dialogs/devtools/RoomNotifications.tsx | 29 +++++++++++++++---- src/i18n/strings/en_EN.json | 5 ++-- .../RoomNotifications-test.tsx.snap | 26 ++++++++++------- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/components/views/dialogs/devtools/RoomNotifications.tsx b/src/components/views/dialogs/devtools/RoomNotifications.tsx index 7ddfb5d8baa..be11eea7abd 100644 --- a/src/components/views/dialogs/devtools/RoomNotifications.tsx +++ b/src/components/views/dialogs/devtools/RoomNotifications.tsx @@ -48,13 +48,32 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme )}
  • - {_t("Notification state is")} {notificationState} + {_t( + "Notification state is %(notificationState)s", + { + notificationState, + }, + { + strong: (sub) => {sub}, + }, + )}
  • - {_t("Room is ")} - - {cli.isRoomEncrypted(room.roomId!) ? _t("encrypted ✅") : _t("not encrypted 🚨")} - + {cli.isRoomEncrypted(room.roomId!) + ? _t( + "Room is encrypted ✅", + {}, + { + strong: (sub) => {sub}, + }, + ) + : _t( + "Room is not encrypted 🚨", + {}, + { + strong: (sub) => {sub}, + }, + )}
  • diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 7681df7d182..3569721e31b 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -3157,9 +3157,8 @@ "Room unread status: ": "Room unread status: ", ", count:": ", count:", "Notification state is %(notificationState)s": "Notification state is %(notificationState)s", - "Room is ": "Room is ", - "encrypted ✅": "encrypted ✅", - "not encrypted 🚨": "not encrypted 🚨", + "Room is encrypted ✅": "Room is encrypted ✅", + "Room is not encrypted 🚨": "Room is not encrypted 🚨", "Main timeline": "Main timeline", "Total: ": "Total: ", "Highlight: ": "Highlight: ", diff --git a/test/components/views/dialogs/devtools/__snapshots__/RoomNotifications-test.tsx.snap b/test/components/views/dialogs/devtools/__snapshots__/RoomNotifications-test.tsx.snap index 79e85f57e9e..843ee88ca5c 100644 --- a/test/components/views/dialogs/devtools/__snapshots__/RoomNotifications-test.tsx.snap +++ b/test/components/views/dialogs/devtools/__snapshots__/RoomNotifications-test.tsx.snap @@ -11,20 +11,26 @@ exports[` should render 1`] = `
    • - Room unread status: - - None - + + Room unread status: + + None + +
    • - Notification state is - + + Notification state is + +
    • - Room is - - not encrypted 🚨 - + + Room is + + not encrypted 🚨 + +
    From 0f655bcbd47eae90c303ca1fb64b1e5605897398 Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Tue, 14 Feb 2023 18:38:21 +0900 Subject: [PATCH 3/5] Clarify context for Weblate translators Signed-off-by: Suguru Hirahara --- .../dialogs/devtools/RoomNotifications.tsx | 21 ++++++++++++++++--- src/i18n/strings/en_EN.json | 4 ++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/components/views/dialogs/devtools/RoomNotifications.tsx b/src/components/views/dialogs/devtools/RoomNotifications.tsx index be11eea7abd..5a7d4fd633c 100644 --- a/src/components/views/dialogs/devtools/RoomNotifications.tsx +++ b/src/components/views/dialogs/devtools/RoomNotifications.tsx @@ -39,11 +39,26 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme

    {_t("Room status")}

    • - {_t("Room unread status: ")} - {humanReadableNotificationColor(color)} + {_t( + "Room unread status: %(roomUnreadStatus)s", + { + roomUnreadStatus: humanReadableNotificationColor(color), + }, + { + strong: (sub) => {sub}, + }, + )} {count > 0 && ( <> - {_t(", count:")} {count} + {_t( + ", count: %(roomUnreadCount)s", + { + roomUnreadCount: count, + }, + { + strong: (sub) => {sub}, + }, + )} )}
    • diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 3569721e31b..8cac99271d2 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -3154,8 +3154,8 @@ "Filter results": "Filter results", "No results found": "No results found", "Room status": "Room status", - "Room unread status: ": "Room unread status: ", - ", count:": ", count:", + "Room unread status: %(roomUnreadStatus)s": "Room unread status: %(roomUnreadStatus)s", + ", count: %(roomUnreadCount)s": ", count: %(roomUnreadCount)s", "Notification state is %(notificationState)s": "Notification state is %(notificationState)s", "Room is encrypted ✅": "Room is encrypted ✅", "Room is not encrypted 🚨": "Room is not encrypted 🚨", From 118a0daac608c3e7df00bd1e0004ebe5f7f8b7e4 Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Fri, 17 Feb 2023 16:58:48 +0900 Subject: [PATCH 4/5] apply feedback comments Signed-off-by: Suguru Hirahara --- .../dialogs/devtools/RoomNotifications.tsx | 44 ++++++------------- src/i18n/strings/en_EN.json | 3 +- 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/src/components/views/dialogs/devtools/RoomNotifications.tsx b/src/components/views/dialogs/devtools/RoomNotifications.tsx index 5a7d4fd633c..25f4110ec11 100644 --- a/src/components/views/dialogs/devtools/RoomNotifications.tsx +++ b/src/components/views/dialogs/devtools/RoomNotifications.tsx @@ -20,7 +20,7 @@ import React, { useContext } from "react"; import MatrixClientContext from "../../../../contexts/MatrixClientContext"; import { useNotificationState } from "../../../../hooks/useRoomNotificationState"; -import { _t } from "../../../../languageHandler"; +import { _t, _td } from "../../../../languageHandler"; import { determineUnreadState } from "../../../../RoomNotifs"; import { humanReadableNotificationColor } from "../../../../stores/notifications/NotificationColor"; import { doesRoomOrThreadHaveUnreadMessages } from "../../../../Unread"; @@ -40,27 +40,15 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme
      • {_t( - "Room unread status: %(roomUnreadStatus)s", + "Room unread status: %(status)s, count: %(count)s", { - roomUnreadStatus: humanReadableNotificationColor(color), + status: humanReadableNotificationColor(color), + count, }, { strong: (sub) => {sub}, }, )} - {count > 0 && ( - <> - {_t( - ", count: %(roomUnreadCount)s", - { - roomUnreadCount: count, - }, - { - strong: (sub) => {sub}, - }, - )} - - )}
      • {_t( @@ -74,21 +62,15 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme )}
      • - {cli.isRoomEncrypted(room.roomId!) - ? _t( - "Room is encrypted ✅", - {}, - { - strong: (sub) => {sub}, - }, - ) - : _t( - "Room is not encrypted 🚨", - {}, - { - strong: (sub) => {sub}, - }, - )} + {_t( + cli.isRoomEncrypted(room.roomId!) + ? _td("Room is encrypted ✅") + : _td("Room is not encrypted 🚨"), + {}, + { + strong: (sub) => {sub}, + }, + )}
      diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8cac99271d2..2ab68355e9c 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -3154,8 +3154,7 @@ "Filter results": "Filter results", "No results found": "No results found", "Room status": "Room status", - "Room unread status: %(roomUnreadStatus)s": "Room unread status: %(roomUnreadStatus)s", - ", count: %(roomUnreadCount)s": ", count: %(roomUnreadCount)s", + "Room unread status: %(status)s, count: %(count)s|other": "Room unread status: %(status)s, count: %(count)s", "Notification state is %(notificationState)s": "Notification state is %(notificationState)s", "Room is encrypted ✅": "Room is encrypted ✅", "Room is not encrypted 🚨": "Room is not encrypted 🚨", From e62af0577cbe8e26f480b310a162ec554a4e1c0d Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Tue, 21 Feb 2023 02:33:35 +0900 Subject: [PATCH 5/5] Add a line for zero Signed-off-by: Suguru Hirahara --- src/i18n/strings/en_EN.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 3e51936ab19..5138159597d 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -3145,6 +3145,7 @@ "No results found": "No results found", "Room status": "Room status", "Room unread status: %(status)s, count: %(count)s|other": "Room unread status: %(status)s, count: %(count)s", + "Room unread status: %(status)s, count: %(count)s|zero": "Room unread status: %(status)s", "Notification state is %(notificationState)s": "Notification state is %(notificationState)s", "Room is encrypted ✅": "Room is encrypted ✅", "Room is not encrypted 🚨": "Room is not encrypted 🚨",