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

Commit

Permalink
Consolidate conjugation i18n strings (#11660)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Sep 25, 2023
1 parent f841757 commit 0f59298
Show file tree
Hide file tree
Showing 59 changed files with 371 additions and 283 deletions.
2 changes: 1 addition & 1 deletion cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"target": "es2016",
"jsx": "react",
"lib": ["es2020", "dom", "dom.iterable"],
"lib": ["es2021", "dom", "dom.iterable"],
"types": ["cypress", "cypress-axe", "@percy/cypress", "@testing-library/cypress"],
"resolveJsonModule": true,
"esModuleInterop": true,
Expand Down
11 changes: 3 additions & 8 deletions src/MatrixClientPeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { SettingLevel } from "./settings/SettingLevel";
import MatrixClientBackedController from "./settings/controllers/MatrixClientBackedController";
import ErrorDialog from "./components/views/dialogs/ErrorDialog";
import PlatformPeg from "./PlatformPeg";
import { formatList } from "./utils/FormattingUtils";

export interface IMatrixClientCreds {
homeserverUrl: string;
Expand Down Expand Up @@ -356,15 +357,9 @@ class MatrixClientPegClass implements IMatrixClientPeg {
if (name) return name;

if (names.length === 2 && count === 2) {
return _t("user1_and_user2", {
user1: names[0],
user2: names[1],
});
return formatList(names);
}
return _t("user_and_n_others", {
user: names[0],
count: count - 1,
});
return formatList(names, 1);
}

private inviteeNamesToRoomName(names: string[], count: number): string {
Expand Down
6 changes: 3 additions & 3 deletions src/components/views/elements/EventListSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React, { ComponentProps, ReactNode } from "react";
import { MatrixEvent, RoomMember, EventType } from "matrix-js-sdk/src/matrix";

import { _t } from "../../../languageHandler";
import { formatCommaSeparatedList } from "../../../utils/FormattingUtils";
import { formatList } from "../../../utils/FormattingUtils";
import { isValid3pidInvite } from "../../../RoomInvite";
import GenericEventListSummary from "./GenericEventListSummary";
import { RightPanelPhases } from "../../../stores/right-panel/RightPanelStorePhases";
Expand Down Expand Up @@ -131,7 +131,7 @@ export default class EventListSummary extends React.Component<
return EventListSummary.getDescriptionForTransition(t.transitionType, userNames.length, t.repeats);
});

const desc = formatCommaSeparatedList(descs);
const desc = formatList(descs);

return _t("timeline|summary|format", { nameList, transitionList: desc });
});
Expand All @@ -150,7 +150,7 @@ export default class EventListSummary extends React.Component<
* included before "and [n] others".
*/
private renderNameList(users: string[]): string {
return formatCommaSeparatedList(users, this.props.summaryLength);
return formatList(users, this.props.summaryLength);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/views/messages/MPollBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { PollResponseEvent } from "matrix-js-sdk/src/extensible_events_v1/PollRe
import { _t } from "../../../languageHandler";
import Modal from "../../../Modal";
import { IBodyProps } from "./IBodyProps";
import { formatCommaSeparatedList } from "../../../utils/FormattingUtils";
import { formatList } from "../../../utils/FormattingUtils";
import MatrixClientContext from "../../../contexts/MatrixClientContext";
import ErrorDialog from "../dialogs/ErrorDialog";
import { GetRelationsForEvent } from "../rooms/EventTile";
Expand Down Expand Up @@ -100,7 +100,7 @@ export function findTopAnswer(pollEvent: MatrixEvent, voteRelations: Relations):

const bestAnswerTexts = bestAnswerIds.map(findAnswerText);

return formatCommaSeparatedList(bestAnswerTexts, 3);
return formatList(bestAnswerTexts, 3);
}

export function isPollEnded(pollEvent: MatrixEvent, matrixClient: MatrixClient): boolean {
Expand Down
4 changes: 2 additions & 2 deletions src/components/views/messages/ReactionsRowButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { MatrixEvent } from "matrix-js-sdk/src/matrix";

import { mediaFromMxc } from "../../../customisations/Media";
import { _t } from "../../../languageHandler";
import { formatCommaSeparatedList } from "../../../utils/FormattingUtils";
import { formatList } from "../../../utils/FormattingUtils";
import dis from "../../../dispatcher/dispatcher";
import ReactionsRowButtonTooltip from "./ReactionsRowButtonTooltip";
import AccessibleButton from "../elements/AccessibleButton";
Expand Down Expand Up @@ -123,7 +123,7 @@ export default class ReactionsRowButton extends React.PureComponent<IProps, ISta
undefined;
}

const reactors = formatCommaSeparatedList(senders, 6);
const reactors = formatList(senders, 6);
if (content) {
label = _t("timeline|reactions|label", {
reactors,
Expand Down
4 changes: 2 additions & 2 deletions src/components/views/messages/ReactionsRowButtonTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { MatrixEvent } from "matrix-js-sdk/src/matrix";

import { unicodeToShortcode } from "../../../HtmlUtils";
import { _t } from "../../../languageHandler";
import { formatCommaSeparatedList } from "../../../utils/FormattingUtils";
import { formatList } from "../../../utils/FormattingUtils";
import Tooltip from "../elements/Tooltip";
import MatrixClientContext from "../../../contexts/MatrixClientContext";
import { REACTION_SHORTCODE_KEY } from "./ReactionsRow";
Expand Down Expand Up @@ -66,7 +66,7 @@ export default class ReactionsRowButtonTooltip extends React.PureComponent<IProp
},
{
reactors: () => {
return <div className="mx_Tooltip_title">{formatCommaSeparatedList(senders, 6)}</div>;
return <div className="mx_Tooltip_title">{formatList(senders, 6)}</div>;
},
reactedWith: (sub) => {
if (!shortName) {
Expand Down
85 changes: 37 additions & 48 deletions src/components/views/rooms/RoomKnocksBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import ErrorDialog from "../dialogs/ErrorDialog";
import { RoomSettingsTab } from "../dialogs/RoomSettingsDialog";
import AccessibleButton from "../elements/AccessibleButton";
import Heading from "../typography/Heading";
import { formatList } from "../../../utils/FormattingUtils";

export const RoomKnocksBar: VFC<{ room: Room }> = ({ room }) => {
const [disabled, setDisabled] = useState(false);
Expand Down Expand Up @@ -82,58 +83,46 @@ export const RoomKnocksBar: VFC<{ room: Room }> = ({ room }) => {
{_t("action|view")}
</AccessibleButton>
);
let names: string = knockMembers
.slice(0, 2)
.map((knockMember) => knockMember.name)
.join(", ");
let names = formatList(
knockMembers.map((knockMember) => knockMember.name),
3,
true,
);
let link: ReactNode = null;
switch (knockMembersCount) {
case 1: {
buttons = (
<>
<AccessibleButton
className="mx_RoomKnocksBar_action"
disabled={!canKick || disabled}
kind="icon_primary_outline"
onClick={() => handleDeny(knockMembers[0].userId)}
title={_t("action|deny")}
>
<XIcon width={18} height={18} />
</AccessibleButton>
<AccessibleButton
className="mx_RoomKnocksBar_action"
disabled={!canInvite || disabled}
kind="icon_primary"
onClick={() => handleApprove(knockMembers[0].userId)}
title={_t("action|approve")}
>
<CheckIcon width={18} height={18} />
</AccessibleButton>
</>
);
names = `${knockMembers[0].name} (${knockMembers[0].userId})`;
link = knockMembers[0].events.member?.getContent().reason && (
if (knockMembersCount === 1) {
buttons = (
<>
<AccessibleButton
className="mx_RoomKnocksBar_action"
disabled={!canKick || disabled}
kind="icon_primary_outline"
onClick={() => handleDeny(knockMembers[0].userId)}
title={_t("action|deny")}
>
<XIcon width={18} height={18} />
</AccessibleButton>
<AccessibleButton
className="mx_RoomKnocksBar_link"
element="a"
kind="link_inline"
onClick={handleOpenRoomSettings}
className="mx_RoomKnocksBar_action"
disabled={!canInvite || disabled}
kind="icon_primary"
onClick={() => handleApprove(knockMembers[0].userId)}
title={_t("action|approve")}
>
{_t("action|view_message")}
<CheckIcon width={18} height={18} />
</AccessibleButton>
);
break;
}
case 2: {
names = _t("%(names)s and %(name)s", { names: knockMembers[0].name, name: knockMembers[1].name });
break;
}
case 3: {
names = _t("%(names)s and %(name)s", { names, name: knockMembers[2].name });
break;
}
default:
names = _t("%(names)s and %(count)s others", { names, count: knockMembersCount - 2 });
</>
);
names = `${knockMembers[0].name} (${knockMembers[0].userId})`;
link = knockMembers[0].events.member?.getContent().reason && (
<AccessibleButton
className="mx_RoomKnocksBar_link"
element="a"
kind="link_inline"
onClick={handleOpenRoomSettings}
>
{_t("action|view_message")}
</AccessibleButton>
);
}

return (
Expand Down
6 changes: 3 additions & 3 deletions src/i18n/strings/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@
"Delete widget": "Изтрий приспособлението",
"Create new room": "Създай нова стая",
"Home": "Начална страница",
"%(items)s and %(count)s others": {
"other": "%(items)s и %(count)s други",
"one": "%(items)s и още един"
"<Items/> and %(count)s others": {
"other": "<Items/> и %(count)s други",
"one": "<Items/> и още един"
},
"%(items)s and %(lastItem)s": "%(items)s и %(lastItem)s",
"collapse": "свий",
Expand Down
6 changes: 3 additions & 3 deletions src/i18n/strings/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@
"Deleting a widget removes it for all users in this room. Are you sure you want to delete this widget?": "La supressió d'un giny l'elimina per a tots els usuaris d'aquesta sala. Esteu segur que voleu eliminar aquest giny?",
"Delete widget": "Suprimeix el giny",
"Home": "Inici",
"%(items)s and %(count)s others": {
"other": "%(items)s i %(count)s altres",
"one": "%(items)s i un altre"
"<Items/> and %(count)s others": {
"other": "<Items/> i %(count)s altres",
"one": "<Items/> i un altre"
},
"%(items)s and %(lastItem)s": "%(items)s i %(lastItem)s",
"collapse": "col·lapsa",
Expand Down
6 changes: 3 additions & 3 deletions src/i18n/strings/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@
"Invalid file%(extra)s": "Neplatný soubor%(extra)s",
"You are about to be taken to a third-party site so you can authenticate your account for use with %(integrationsUrl)s. Do you wish to continue?": "Budete přesměrováni na stránku třetí strany k ověření svého účtu pro používání s %(integrationsUrl)s. Chcete pokračovat?",
"Something went wrong!": "Něco se nepodařilo!",
"%(items)s and %(count)s others": {
"other": "%(items)s a %(count)s další",
"one": "%(items)s a jeden další"
"<Items/> and %(count)s others": {
"other": "<Items/> a %(count)s další",
"one": "<Items/> a jeden další"
},
"%(items)s and %(lastItem)s": "%(items)s a také %(lastItem)s",
"And %(count)s more...": {
Expand Down
6 changes: 3 additions & 3 deletions src/i18n/strings/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
"Preparing to send logs": "Forbereder afsendelse af logfiler",
"Permission Required": "Tilladelse påkrævet",
"%(weekDayName)s, %(monthName)s %(day)s %(fullYear)s": "%(weekDayName)s, %(day)s. %(monthName)s %(fullYear)s",
"%(items)s and %(count)s others": {
"other": "%(items)s og %(count)s andre",
"one": "%(items)s og en anden"
"<Items/> and %(count)s others": {
"other": "<Items/> og %(count)s andre",
"one": "<Items/> og en anden"
},
"%(items)s and %(lastItem)s": "%(items)s og %(lastItem)s",
"Please contact your homeserver administrator.": "Kontakt venligst din homeserver administrator.",
Expand Down
6 changes: 3 additions & 3 deletions src/i18n/strings/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@
},
"Delete Widget": "Widget löschen",
"Deleting a widget removes it for all users in this room. Are you sure you want to delete this widget?": "Das Löschen des Widgets entfernt es für alle in diesem Raum. Wirklich löschen?",
"%(items)s and %(count)s others": {
"other": "%(items)s und %(count)s andere",
"one": "%(items)s und ein weiteres Raummitglied"
"<Items/> and %(count)s others": {
"other": "<Items/> und %(count)s andere",
"one": "<Items/> und ein weiteres Raummitglied"
},
"Restricted": "Eingeschränkt",
"%(duration)ss": "%(duration)ss",
Expand Down
6 changes: 3 additions & 3 deletions src/i18n/strings/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@
"Your homeserver has exceeded its user limit.": "Ο διακομιστής σας ξεπέρασε το όριο χρηστών.",
"Use app": "Χρησιμοποιήστε την εφαρμογή",
"Use app for a better experience": "Χρησιμοποιήστε την εφαρμογή για καλύτερη εμπειρία",
"%(items)s and %(count)s others": {
"one": "%(items)s και ένα ακόμα",
"other": "%(items)s και %(count)s άλλα"
"<Items/> and %(count)s others": {
"one": "<Items/> και ένα ακόμα",
"other": "<Items/> και %(count)s άλλα"
},
"Ask this user to verify their session, or manually verify it below.": "Ζητήστε από αυτόν τον χρήστη να επιβεβαιώσει την συνεδρία του, ή επιβεβαιώστε την χειροκίνητα παρακάτω.",
"%(name)s (%(userId)s) signed in to a new session without verifying it:": "Ο %(name)s (%(userId)s) συνδέθηκε σε μία νέα συνεδρία χωρίς να την επιβεβαιώσει:",
Expand Down
26 changes: 5 additions & 21 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -764,15 +764,10 @@
"error_database_closed_title": "Database unexpectedly closed",
"error_database_closed_description": "This may be caused by having the app open in multiple tabs or due to clearing browser data.",
"empty_room": "Empty room",
"user1_and_user2": "%(user1)s and %(user2)s",
"user_and_n_others": {
"other": "%(user)s and %(count)s others",
"one": "%(user)s and 1 other"
},
"inviting_user1_and_user2": "Inviting %(user1)s and %(user2)s",
"inviting_user_and_n_others": {
"other": "Inviting %(user)s and %(count)s others",
"one": "Inviting %(user)s and 1 other"
"one": "Inviting %(user)s and one other"
},
"empty_room_was_name": "Empty room (was %(oldName)s)",
"notifier": {
Expand Down Expand Up @@ -1403,20 +1398,14 @@
"mixed_content": "Can't connect to homeserver via HTTP when an HTTPS URL is in your browser bar. Either use HTTPS or <a>enable unsafe scripts</a>.",
"tls": "Can't connect to homeserver - please check your connectivity, ensure your <a>homeserver's SSL certificate</a> is trusted, and that a browser extension is not blocking requests."
},
"%(items)s and %(count)s others": {
"other": "%(items)s and %(count)s others",
"one": "%(items)s and one other"
"<Items/> and %(count)s others": {
"other": "<Items/> and %(count)s others",
"one": "<Items/> and one other"
},
"%(items)s and %(lastItem)s": "%(items)s and %(lastItem)s",
"%(space1Name)s and %(space2Name)s": "%(space1Name)s and %(space2Name)s",
"in_space1_and_space2": "In spaces %(space1Name)s and %(space2Name)s.",
"%(spaceName)s and %(count)s others": {
"other": "%(spaceName)s and %(count)s others",
"one": "%(spaceName)s and %(count)s other"
},
"in_space_and_n_other_spaces": {
"other": "In %(spaceName)s and %(count)s other spaces.",
"one": "In %(spaceName)s and %(count)s other space."
"one": "In %(spaceName)s and one other space."
},
"in_space": "In %(spaceName)s.",
"name_and_id": "%(name)s (%(userId)s)",
Expand Down Expand Up @@ -2571,11 +2560,6 @@
"Public space": "Public space",
"Private space": "Private space",
"Private room": "Private room",
"%(names)s and %(name)s": "%(names)s and %(name)s",
"%(names)s and %(count)s others": {
"other": "%(names)s and %(count)s others",
"one": "%(names)s and %(count)s other"
},
"%(count)s people asking to join": {
"other": "%(count)s people asking to join",
"one": "Asking to join"
Expand Down
6 changes: 3 additions & 3 deletions src/i18n/strings/eo.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
"Delete widget": "Forigi fenestraĵon",
"Create new room": "Krei novan ĉambron",
"Home": "Hejmo",
"%(items)s and %(count)s others": {
"other": "%(items)s kaj %(count)s aliaj",
"one": "%(items)s kaj unu alia"
"<Items/> and %(count)s others": {
"other": "<Items/> kaj %(count)s aliaj",
"one": "<Items/> kaj unu alia"
},
"%(items)s and %(lastItem)s": "%(items)s kaj %(lastItem)s",
"collapse": "maletendi",
Expand Down
6 changes: 3 additions & 3 deletions src/i18n/strings/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@
"Delete Widget": "Eliminar accesorio",
"Deleting a widget removes it for all users in this room. Are you sure you want to delete this widget?": "Al borrar un accesorio, este se elimina para todos usuarios de la sala. ¿Estás seguro?",
"Popout widget": "Abrir accesorio en una ventana emergente",
"%(items)s and %(count)s others": {
"other": "%(items)s y otros %(count)s",
"one": "%(items)s y otro más"
"<Items/> and %(count)s others": {
"other": "<Items/> y otros %(count)s",
"one": "<Items/> y otro más"
},
"collapse": "encoger",
"expand": "desplegar",
Expand Down
6 changes: 3 additions & 3 deletions src/i18n/strings/et.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,9 @@
"Identity server URL does not appear to be a valid identity server": "Isikutuvastusserveri aadress ei tundu viitama kehtivale isikutuvastusserverile",
"Looks good!": "Tundub õige!",
"Failed to re-authenticate due to a homeserver problem": "Uuesti autentimine ei õnnestunud koduserveri vea tõttu",
"%(items)s and %(count)s others": {
"other": "%(items)s ja %(count)s muud",
"one": "%(items)s ja üks muu"
"<Items/> and %(count)s others": {
"other": "<Items/> ja %(count)s muud",
"one": "<Items/> ja üks muu"
},
"%(items)s and %(lastItem)s": "%(items)s ja %(lastItem)s",
"Please contact your homeserver administrator.": "Palun võta ühendust koduserveri haldajaga.",
Expand Down
Loading

0 comments on commit 0f59298

Please sign in to comment.