Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b9ff655

Browse files
authored
Make localization keys compatible with agglutinative and/or SOV type languages (#10159)
* Make localization keys on HelpUserSettingsTab compatible with agglutinative and/or SOV type languages * Make localization keys on room notifications debug dialog on devtools compatible with agglutinative and/or SOV type languages * Make keys compatible with inflection * Clarify context for Weblate translators --------- Signed-off-by: Suguru Hirahara <[email protected]>
1 parent e455211 commit b9ff655

File tree

4 files changed

+69
-32
lines changed

4 files changed

+69
-32
lines changed

src/components/views/dialogs/devtools/RoomNotifications.tsx

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import React, { useContext } from "react";
2020

2121
import MatrixClientContext from "../../../../contexts/MatrixClientContext";
2222
import { useNotificationState } from "../../../../hooks/useRoomNotificationState";
23-
import { _t } from "../../../../languageHandler";
23+
import { _t, _td } from "../../../../languageHandler";
2424
import { determineUnreadState } from "../../../../RoomNotifs";
2525
import { humanReadableNotificationColor } from "../../../../stores/notifications/NotificationColor";
2626
import { doesRoomOrThreadHaveUnreadMessages } from "../../../../Unread";
@@ -39,22 +39,38 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme
3939
<h2>{_t("Room status")}</h2>
4040
<ul>
4141
<li>
42-
{_t("Room unread status: ")}
43-
<strong>{humanReadableNotificationColor(color)}</strong>
44-
{count > 0 && (
45-
<>
46-
{_t(", count:")} <strong>{count}</strong>
47-
</>
42+
{_t(
43+
"Room unread status: <strong>%(status)s</strong>, count: <strong>%(count)s</strong>",
44+
{
45+
status: humanReadableNotificationColor(color),
46+
count,
47+
},
48+
{
49+
strong: (sub) => <strong>{sub}</strong>,
50+
},
4851
)}
4952
</li>
5053
<li>
51-
{_t("Notification state is")} <strong>{notificationState}</strong>
54+
{_t(
55+
"Notification state is <strong>%(notificationState)s</strong>",
56+
{
57+
notificationState,
58+
},
59+
{
60+
strong: (sub) => <strong>{sub}</strong>,
61+
},
62+
)}
5263
</li>
5364
<li>
54-
{_t("Room is ")}
55-
<strong>
56-
{cli.isRoomEncrypted(room.roomId!) ? _t("encrypted ✅") : _t("not encrypted 🚨")}
57-
</strong>
65+
{_t(
66+
cli.isRoomEncrypted(room.roomId!)
67+
? _td("Room is <strong>encrypted ✅</strong>")
68+
: _td("Room is <strong>not encrypted 🚨</strong>"),
69+
{},
70+
{
71+
strong: (sub) => <strong>{sub}</strong>,
72+
},
73+
)}
5874
</li>
5975
</ul>
6076
</section>

src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,26 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
327327
<span className="mx_SettingsTab_subheading">{_t("Advanced")}</span>
328328
<div className="mx_SettingsTab_subsectionText">
329329
<div>
330-
{_t("Homeserver is")} <code>{MatrixClientPeg.get().getHomeserverUrl()}</code>
330+
{_t(
331+
"Homeserver is <code>%(homeserverUrl)s</code>",
332+
{
333+
homeserverUrl: MatrixClientPeg.get().getHomeserverUrl(),
334+
},
335+
{
336+
code: (sub) => <code>{sub}</code>,
337+
},
338+
)}
331339
</div>
332340
<div>
333-
{_t("Identity server is")} <code>{MatrixClientPeg.get().getIdentityServerUrl()}</code>
341+
{_t(
342+
"Identity server is <code>%(identityServerUrl)s</code>",
343+
{
344+
identityServerUrl: MatrixClientPeg.get().getIdentityServerUrl(),
345+
},
346+
{
347+
code: (sub) => <code>{sub}</code>,
348+
},
349+
)}
334350
</div>
335351
<details>
336352
<summary>{_t("Access Token")}</summary>

src/i18n/strings/en_EN.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,8 +1567,8 @@
15671567
"FAQ": "FAQ",
15681568
"Keyboard Shortcuts": "Keyboard Shortcuts",
15691569
"Versions": "Versions",
1570-
"Homeserver is": "Homeserver is",
1571-
"Identity server is": "Identity server is",
1570+
"Homeserver is <code>%(homeserverUrl)s</code>": "Homeserver is <code>%(homeserverUrl)s</code>",
1571+
"Identity server is <code>%(identityServerUrl)s</code>": "Identity server is <code>%(identityServerUrl)s</code>",
15721572
"Access Token": "Access Token",
15731573
"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.",
15741574
"Clear cache and reload": "Clear cache and reload",
@@ -3150,12 +3150,11 @@
31503150
"Filter results": "Filter results",
31513151
"No results found": "No results found",
31523152
"Room status": "Room status",
3153-
"Room unread status: ": "Room unread status: ",
3154-
", count:": ", count:",
3155-
"Notification state is": "Notification state is",
3156-
"Room is ": "Room is ",
3157-
"encrypted ✅": "encrypted ✅",
3158-
"not encrypted 🚨": "not encrypted 🚨",
3153+
"Room unread status: <strong>%(status)s</strong>, count: <strong>%(count)s</strong>|other": "Room unread status: <strong>%(status)s</strong>, count: <strong>%(count)s</strong>",
3154+
"Room unread status: <strong>%(status)s</strong>, count: <strong>%(count)s</strong>|zero": "Room unread status: <strong>%(status)s</strong>",
3155+
"Notification state is <strong>%(notificationState)s</strong>": "Notification state is <strong>%(notificationState)s</strong>",
3156+
"Room is <strong>encrypted ✅</strong>": "Room is <strong>encrypted ✅</strong>",
3157+
"Room is <strong>not encrypted 🚨</strong>": "Room is <strong>not encrypted 🚨</strong>",
31593158
"Main timeline": "Main timeline",
31603159
"Total: ": "Total: ",
31613160
"Highlight: ": "Highlight: ",

test/components/views/dialogs/devtools/__snapshots__/RoomNotifications-test.tsx.snap

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,26 @@ exports[`<RoomNotifications /> should render 1`] = `
1111
</h2>
1212
<ul>
1313
<li>
14-
Room unread status:
15-
<strong>
16-
None
17-
</strong>
14+
<span>
15+
Room unread status:
16+
<strong>
17+
None
18+
</strong>
19+
</span>
1820
</li>
1921
<li>
20-
Notification state is
21-
<strong />
22+
<span>
23+
Notification state is
24+
<strong />
25+
</span>
2226
</li>
2327
<li>
24-
Room is
25-
<strong>
26-
not encrypted 🚨
27-
</strong>
28+
<span>
29+
Room is
30+
<strong>
31+
not encrypted 🚨
32+
</strong>
33+
</span>
2834
</li>
2935
</ul>
3036
</section>

0 commit comments

Comments
 (0)