From 8b9719d46aac23e4f1acd22c2d7bcd76f91b60f8 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 8 Sep 2023 09:58:31 +0100 Subject: [PATCH] Migrate more strings to translation keys (#11579) --- src/TextForEvent.tsx | 53 +++--- .../views/beacon/LiveTimeRemaining.tsx | 2 +- .../views/settings/FontScalingPanel.tsx | 10 +- .../views/settings/ImageSizePanel.tsx | 2 +- .../views/settings/Notifications.tsx | 20 +- .../views/settings/ThemeChoicePanel.tsx | 19 +- .../notifications/NotificationSettings2.tsx | 6 +- .../tabs/user/AppearanceUserSettingsTab.tsx | 11 +- src/effects/index.ts | 24 +-- src/i18n/strings/ar.json | 102 +++++----- src/i18n/strings/az.json | 14 +- src/i18n/strings/bg.json | 117 +++++++----- src/i18n/strings/ca.json | 20 +- src/i18n/strings/cs.json | 157 +++++++++------- src/i18n/strings/da.json | 57 +++--- src/i18n/strings/de_DE.json | 157 +++++++++------- src/i18n/strings/el.json | 147 ++++++++------- src/i18n/strings/en_EN.json | 174 ++++++++++-------- src/i18n/strings/en_US.json | 17 +- src/i18n/strings/eo.json | 132 +++++++------ src/i18n/strings/es.json | 157 +++++++++------- src/i18n/strings/et.json | 157 +++++++++------- src/i18n/strings/eu.json | 95 +++++----- src/i18n/strings/fa.json | 130 +++++++------ src/i18n/strings/fi.json | 155 +++++++++------- src/i18n/strings/fr.json | 157 +++++++++------- src/i18n/strings/ga.json | 14 +- src/i18n/strings/gl.json | 151 ++++++++------- src/i18n/strings/he.json | 142 +++++++------- src/i18n/strings/hi.json | 17 +- src/i18n/strings/hu.json | 157 +++++++++------- src/i18n/strings/id.json | 157 +++++++++------- src/i18n/strings/is.json | 155 +++++++++------- src/i18n/strings/it.json | 157 +++++++++------- src/i18n/strings/ja.json | 157 +++++++++------- src/i18n/strings/jbo.json | 36 ++-- src/i18n/strings/kab.json | 102 +++++----- src/i18n/strings/ko.json | 26 ++- src/i18n/strings/lo.json | 151 ++++++++------- src/i18n/strings/lt.json | 147 ++++++++------- src/i18n/strings/lv.json | 94 +++++----- src/i18n/strings/nb_NO.json | 44 +++-- src/i18n/strings/nl.json | 157 +++++++++------- src/i18n/strings/nn.json | 70 +++---- src/i18n/strings/oc.json | 12 +- src/i18n/strings/pl.json | 157 +++++++++------- src/i18n/strings/pt.json | 15 +- src/i18n/strings/pt_BR.json | 143 +++++++------- src/i18n/strings/ru.json | 157 +++++++++------- src/i18n/strings/sk.json | 157 +++++++++------- src/i18n/strings/sq.json | 157 +++++++++------- src/i18n/strings/sr.json | 92 +++++---- src/i18n/strings/sr_Latn.json | 5 +- src/i18n/strings/sv.json | 157 +++++++++------- src/i18n/strings/ta.json | 7 +- src/i18n/strings/te.json | 3 + src/i18n/strings/th.json | 13 +- src/i18n/strings/tr.json | 116 +++++++----- src/i18n/strings/tzm.json | 3 + src/i18n/strings/uk.json | 157 +++++++++------- src/i18n/strings/vi.json | 153 ++++++++------- src/i18n/strings/vls.json | 19 +- src/i18n/strings/zh_Hans.json | 157 +++++++++------- src/i18n/strings/zh_Hant.json | 157 +++++++++------- src/settings/Settings.tsx | 32 ++-- 65 files changed, 3334 insertions(+), 2561 deletions(-) diff --git a/src/TextForEvent.tsx b/src/TextForEvent.tsx index 55cce111d1..0593c85c5c 100644 --- a/src/TextForEvent.tsx +++ b/src/TextForEvent.tsx @@ -423,7 +423,7 @@ function textForCanonicalAliasEvent(ev: MatrixEvent): (() => string) | null { } else if (newAlias === oldAlias) { if (addedAltAliases.length && !removedAltAliases.length) { return () => - _t("%(senderName)s added the alternative addresses %(addresses)s for this room.", { + _t("timeline|m.room.canonical_alias|alt_added", { senderName, addresses: addedAltAliases.join(", "), count: addedAltAliases.length, @@ -431,7 +431,7 @@ function textForCanonicalAliasEvent(ev: MatrixEvent): (() => string) | null { } if (removedAltAliases.length && !addedAltAliases.length) { return () => - _t("%(senderName)s removed the alternative addresses %(addresses)s for this room.", { + _t("timeline|m.room.canonical_alias|alt_removed", { senderName, addresses: removedAltAliases.join(", "), count: removedAltAliases.length, @@ -547,11 +547,11 @@ function textForPowerEvent(event: MatrixEvent, client: MatrixClient): (() => str // XXX: This is also surely broken for i18n return () => - _t("%(senderName)s changed the power level of %(powerLevelDiffText)s.", { + _t("timeline|m.room.power_levels|changed", { senderName, powerLevelDiffText: diffs .map((diff) => - _t("%(userId)s from %(fromPowerLevel)s to %(toPowerLevel)s", { + _t("timeline|m.room.power_levels|user_from_to", { userId: diff.name, fromPowerLevel: Roles.textualPowerLevel(diff.from, previousUserDefault), toPowerLevel: Roles.textualPowerLevel(diff.to, currentUserDefault), @@ -711,45 +711,43 @@ function textForMjolnirEvent(event: MatrixEvent): (() => string) | null { // Rule removed if (!entity) { if (USER_RULE_TYPES.includes(event.getType())) { - return () => - _t("%(senderName)s removed the rule banning users matching %(glob)s", { senderName, glob: prevEntity }); + return () => _t("timeline|mjolnir|removed_rule_users", { senderName, glob: prevEntity }); } else if (ROOM_RULE_TYPES.includes(event.getType())) { - return () => - _t("%(senderName)s removed the rule banning rooms matching %(glob)s", { senderName, glob: prevEntity }); + return () => _t("timeline|mjolnir|removed_rule_rooms", { senderName, glob: prevEntity }); } else if (SERVER_RULE_TYPES.includes(event.getType())) { return () => - _t("%(senderName)s removed the rule banning servers matching %(glob)s", { + _t("timeline|mjolnir|removed_rule_servers", { senderName, glob: prevEntity, }); } // Unknown type. We'll say something, but we shouldn't end up here. - return () => _t("%(senderName)s removed a ban rule matching %(glob)s", { senderName, glob: prevEntity }); + return () => _t("timeline|mjolnir|removed_rule", { senderName, glob: prevEntity }); } // Invalid rule - if (!recommendation || !reason) return () => _t(`%(senderName)s updated an invalid ban rule`, { senderName }); + if (!recommendation || !reason) return () => _t("timeline|mjolnir|updated_invalid_rule", { senderName }); // Rule updated if (entity === prevEntity) { if (USER_RULE_TYPES.includes(event.getType())) { return () => - _t("%(senderName)s updated the rule banning users matching %(glob)s for %(reason)s", { + _t("timeline|mjolnir|updated_rule_users", { senderName, glob: entity, reason, }); } else if (ROOM_RULE_TYPES.includes(event.getType())) { return () => - _t("%(senderName)s updated the rule banning rooms matching %(glob)s for %(reason)s", { + _t("timeline|mjolnir|updated_rule_rooms", { senderName, glob: entity, reason, }); } else if (SERVER_RULE_TYPES.includes(event.getType())) { return () => - _t("%(senderName)s updated the rule banning servers matching %(glob)s for %(reason)s", { + _t("timeline|mjolnir|updated_rule_servers", { senderName, glob: entity, reason, @@ -758,7 +756,7 @@ function textForMjolnirEvent(event: MatrixEvent): (() => string) | null { // Unknown type. We'll say something but we shouldn't end up here. return () => - _t("%(senderName)s updated a ban rule matching %(glob)s for %(reason)s", { + _t("timeline|mjolnir|updated_rule", { senderName, glob: entity, reason, @@ -769,21 +767,21 @@ function textForMjolnirEvent(event: MatrixEvent): (() => string) | null { if (!prevEntity) { if (USER_RULE_TYPES.includes(event.getType())) { return () => - _t("%(senderName)s created a rule banning users matching %(glob)s for %(reason)s", { + _t("timeline|mjolnir|created_rule_users", { senderName, glob: entity, reason, }); } else if (ROOM_RULE_TYPES.includes(event.getType())) { return () => - _t("%(senderName)s created a rule banning rooms matching %(glob)s for %(reason)s", { + _t("timeline|mjolnir|created_rule_rooms", { senderName, glob: entity, reason, }); } else if (SERVER_RULE_TYPES.includes(event.getType())) { return () => - _t("%(senderName)s created a rule banning servers matching %(glob)s for %(reason)s", { + _t("timeline|mjolnir|created_rule_servers", { senderName, glob: entity, reason, @@ -792,7 +790,7 @@ function textForMjolnirEvent(event: MatrixEvent): (() => string) | null { // Unknown type. We'll say something but we shouldn't end up here. return () => - _t("%(senderName)s created a ban rule matching %(glob)s for %(reason)s", { + _t("timeline|mjolnir|created_rule", { senderName, glob: entity, reason, @@ -802,27 +800,18 @@ function textForMjolnirEvent(event: MatrixEvent): (() => string) | null { // else the entity !== prevEntity - count as a removal & add if (USER_RULE_TYPES.includes(event.getType())) { return () => - _t( - "%(senderName)s changed a rule that was banning users matching %(oldGlob)s to matching %(newGlob)s for %(reason)s", - { senderName, oldGlob: prevEntity, newGlob: entity, reason }, - ); + _t("timeline|mjolnir|changed_rule_users", { senderName, oldGlob: prevEntity, newGlob: entity, reason }); } else if (ROOM_RULE_TYPES.includes(event.getType())) { return () => - _t( - "%(senderName)s changed a rule that was banning rooms matching %(oldGlob)s to matching %(newGlob)s for %(reason)s", - { senderName, oldGlob: prevEntity, newGlob: entity, reason }, - ); + _t("timeline|mjolnir|changed_rule_rooms", { senderName, oldGlob: prevEntity, newGlob: entity, reason }); } else if (SERVER_RULE_TYPES.includes(event.getType())) { return () => - _t( - "%(senderName)s changed a rule that was banning servers matching %(oldGlob)s to matching %(newGlob)s for %(reason)s", - { senderName, oldGlob: prevEntity, newGlob: entity, reason }, - ); + _t("timeline|mjolnir|changed_rule_servers", { senderName, oldGlob: prevEntity, newGlob: entity, reason }); } // Unknown type. We'll say something but we shouldn't end up here. return () => - _t("%(senderName)s updated a ban rule that was matching %(oldGlob)s to matching %(newGlob)s for %(reason)s", { + _t("timeline|mjolnir|changed_rule_glob", { senderName, oldGlob: prevEntity, newGlob: entity, diff --git a/src/components/views/beacon/LiveTimeRemaining.tsx b/src/components/views/beacon/LiveTimeRemaining.tsx index b1fc767f6f..41698013c1 100644 --- a/src/components/views/beacon/LiveTimeRemaining.tsx +++ b/src/components/views/beacon/LiveTimeRemaining.tsx @@ -66,7 +66,7 @@ const LiveTimeRemaining: React.FC<{ beacon: Beacon }> = ({ beacon }) => { const msRemaining = useMsRemaining(beacon); const timeRemaining = formatDuration(msRemaining); - const liveTimeRemaining = _t(`%(timeRemaining)s left`, { timeRemaining }); + const liveTimeRemaining = _t("time|left", { timeRemaining }); return ( diff --git a/src/components/views/settings/FontScalingPanel.tsx b/src/components/views/settings/FontScalingPanel.tsx index a96ff96194..7f4597f5dc 100644 --- a/src/components/views/settings/FontScalingPanel.tsx +++ b/src/components/views/settings/FontScalingPanel.tsx @@ -106,7 +106,11 @@ export default class FontScalingPanel extends React.Component { public render(): React.ReactNode { return ( - + { onChange={this.onFontSizeChanged} displayFunc={(_) => ""} disabled={this.state.useCustomFontSize} - label={_t("Font size")} + label={_t("settings|appearance|font_size")} />
Aa
@@ -148,7 +152,7 @@ export default class FontScalingPanel extends React.Component { { public render(): React.ReactNode { return ( - +