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

Commit

Permalink
Migrate more strings to translation keys (#11613)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Sep 19, 2023
1 parent d46d4b3 commit 5cb8cbd
Show file tree
Hide file tree
Showing 111 changed files with 8,214 additions and 6,766 deletions.
4 changes: 2 additions & 2 deletions src/TextForEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function textForTopicEvent(ev: MatrixEvent): (() => string) | null {

function textForRoomAvatarEvent(ev: MatrixEvent): (() => string) | null {
const senderDisplayName = ev?.sender?.name || ev.getSender();
return () => _t("timeline|m.room.avatar", { senderDisplayName });
return () => _t("timeline|m.room.avatar|changed", { senderDisplayName });
}

function textForRoomNameEvent(ev: MatrixEvent): (() => string) | null {
Expand Down Expand Up @@ -821,7 +821,7 @@ function textForMjolnirEvent(event: MatrixEvent): (() => string) | null {

export function textForLocationEvent(event: MatrixEvent): () => string {
return () =>
_t("timeline|m.location", {
_t("timeline|m.location|full", {
senderName: getSenderName(event),
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/accessibility/KeyboardShortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ if (IS_MAC) {

export const CATEGORIES: Record<CategoryName, ICategory> = {
[CategoryName.COMPOSER]: {
categoryLabel: _td("Composer"),
categoryLabel: _td("settings|preferences|composer_heading"),
settingNames: [
KeyBindingAction.SendMessage,
KeyBindingAction.NewLine,
Expand Down
6 changes: 3 additions & 3 deletions src/actions/RoomListActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class RoomListActions {
return Rooms.guessAndSetDMRoom(room, newTag === DefaultTagID.DM).catch((err) => {
logger.error("Failed to set DM tag " + err);
Modal.createDialog(ErrorDialog, {
title: _t("Failed to set direct message tag"),
title: _t("room_list|failed_set_dm_tag"),
description: err && err.message ? err.message : _t("Operation failed"),
});
});
Expand All @@ -102,7 +102,7 @@ export default class RoomListActions {
const promiseToDelete = matrixClient.deleteRoomTag(roomId, oldTag).catch(function (err) {
logger.error("Failed to remove tag " + oldTag + " from room: " + err);
Modal.createDialog(ErrorDialog, {
title: _t("Failed to remove tag %(tagName)s from room", { tagName: oldTag }),
title: _t("room_list|failed_remove_tag", { tagName: oldTag }),
description: err && err.message ? err.message : _t("Operation failed"),
});
});
Expand All @@ -115,7 +115,7 @@ export default class RoomListActions {
const promiseToAdd = matrixClient.setRoomTag(roomId, newTag, metaData).catch(function (err) {
logger.error("Failed to add tag " + newTag + " to room: " + err);
Modal.createDialog(ErrorDialog, {
title: _t("Failed to add tag %(tagName)s to room", { tagName: newTag }),
title: _t("room_list|failed_add_tag", { tagName: newTag }),
description: err && err.message ? err.message : _t("Operation failed"),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class DisableEventIndexDialog extends React.Component<IProps, ISt
public render(): React.ReactNode {
return (
<BaseDialog onFinished={this.props.onFinished} title={_t("Are you sure?")}>
{_t("If disabled, messages from encrypted rooms won't appear in search results.")}
{_t("settings|security|message_search_disable_warning")}
{this.state.disabling ? <Spinner /> : <div />}
<DialogButtons
primaryButton={_t("action|disable")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,33 +152,33 @@ export default class ManageEventIndexDialog extends React.Component<IProps, ISta

let crawlerState;
if (this.state.currentRoom === null) {
crawlerState = _t("Not currently indexing messages for any room.");
crawlerState = _t("settings|security|message_search_indexing_idle");
} else {
crawlerState = _t("Currently indexing: %(currentRoom)s", { currentRoom: this.state.currentRoom });
crawlerState = _t("settings|security|message_search_indexing", { currentRoom: this.state.currentRoom });
}

const doneRooms = Math.max(0, this.state.roomCount - this.state.crawlingRoomsCount);

const eventIndexingSettings = (
<div>
{_t("%(brand)s is securely caching encrypted messages locally for them to appear in search results:", {
{_t("settings|security|message_search_intro", {
brand,
})}
<div className="mx_SettingsTab_subsectionText">
{crawlerState}
<br />
{_t("Space used:")} {formatBytes(this.state.eventIndexSize, 0)}
{_t("settings|security|message_search_space_used")} {formatBytes(this.state.eventIndexSize, 0)}
<br />
{_t("Indexed messages:")} {formatCountLong(this.state.eventCount)}
{_t("settings|security|message_search_indexed_messages")} {formatCountLong(this.state.eventCount)}
<br />
{_t("Indexed rooms:")}{" "}
{_t("%(doneRooms)s out of %(totalRooms)s", {
{_t("settings|security|message_search_indexed_rooms")}{" "}
{_t("settings|security|message_search_room_progress", {
doneRooms: formatCountLong(doneRooms),
totalRooms: formatCountLong(this.state.roomCount),
})}{" "}
<br />
<Field
label={_t("Message downloading sleep time(ms)")}
label={_t("settings|security|message_search_sleep_time")}
type="number"
value={this.state.crawlerSleepTime.toString()}
onChange={this.onCrawlerSleepTimeChange}
Expand Down
64 changes: 28 additions & 36 deletions src/components/structures/SpaceRoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ const SpaceLanding: React.FC<{ space: Room }> = ({ space }) => {
<RoomName room={space}>
{(name) => {
const tags = { name: () => <h1>{name}</h1> };
return _t("Welcome to <name/>", {}, tags) as JSX.Element;
return _t("space|landing_welcome", {}, tags) as JSX.Element;
}}
</RoomName>
</div>
Expand Down Expand Up @@ -351,7 +351,7 @@ const SpaceSetupFirstRooms: React.FC<{
onFinished(roomIds[0] ?? undefined);
} catch (e) {
logger.error("Failed to create initial space rooms", e);
setError(_t("Failed to create initial space rooms"));
setError(_t("create_space|failed_create_initial_rooms"));
}
setBusy(false);
};
Expand All @@ -360,10 +360,10 @@ const SpaceSetupFirstRooms: React.FC<{
ev.preventDefault();
onFinished();
};
let buttonLabel = _t("Skip for now");
let buttonLabel = _t("create_space|skip_action");
if (roomNames.some((name) => name.trim())) {
onClick = onNextClick;
buttonLabel = busy ? _t("Creating rooms…") : _t("action|continue");
buttonLabel = busy ? _t("create_space|creating_rooms") : _t("action|continue");
}

return (
Expand Down Expand Up @@ -397,18 +397,14 @@ const SpaceAddExistingRooms: React.FC<{
}> = ({ space, onFinished }) => {
return (
<div>
<h1>{_t("What do you want to organise?")}</h1>
<div className="mx_SpaceRoomView_description">
{_t(
"Pick rooms or conversations to add. This is just a space for you, no one will be informed. You can add more later.",
)}
</div>
<h1>{_t("create_space|add_existing_rooms_heading")}</h1>
<div className="mx_SpaceRoomView_description">{_t("create_space|add_existing_rooms_description")}</div>

<AddExistingToSpace
space={space}
emptySelectionButton={
<AccessibleButton kind="primary" onClick={onFinished}>
{_t("Skip for now")}
{_t("create_space|skip_action")}
</AccessibleButton>
}
filterPlaceholder={_t("Search for rooms")}
Expand All @@ -433,19 +429,17 @@ const SpaceSetupPublicShare: React.FC<ISpaceSetupPublicShareProps> = ({
return (
<div className="mx_SpaceRoomView_publicShare">
<h1>
{_t("Share %(name)s", {
{_t("create_space|share_heading", {
name: justCreatedOpts?.createOpts?.name || space.name,
})}
</h1>
<div className="mx_SpaceRoomView_description">
{_t("It's just you at the moment, it will be even better with others.")}
</div>
<div className="mx_SpaceRoomView_description">{_t("create_space|share_description")}</div>

<SpacePublicShare space={space} />

<div className="mx_SpaceRoomView_buttons">
<AccessibleButton kind="primary" onClick={onFinished}>
{firstRoomId ? _t("Go to my first room") : _t("Go to my space")}
{firstRoomId ? _t("create_space|done_action_first_room") : _t("create_space|done_action")}
</AccessibleButton>
</div>
</div>
Expand All @@ -459,9 +453,9 @@ const SpaceSetupPrivateScope: React.FC<{
}> = ({ space, justCreatedOpts, onFinished }) => {
return (
<div className="mx_SpaceRoomView_privateScope">
<h1>{_t("Who are you working with?")}</h1>
<h1>{_t("create_space|private_personal_heading")}</h1>
<div className="mx_SpaceRoomView_description">
{_t("Make sure the right people have access to %(name)s", {
{_t("create_space|private_personal_description", {
name: justCreatedOpts?.createOpts?.name || space.name,
})}
</div>
Expand All @@ -472,17 +466,17 @@ const SpaceSetupPrivateScope: React.FC<{
onFinished(false);
}}
>
{_t("Just me")}
<div>{_t("A private space to organise your rooms")}</div>
{_t("create_space|personal_space")}
<div>{_t("create_space|personal_space_description")}</div>
</AccessibleButton>
<AccessibleButton
className="mx_SpaceRoomView_privateScope_meAndMyTeammatesButton"
onClick={() => {
onFinished(true);
}}
>
{_t("Me and my teammates")}
<div>{_t("A private space for you and your teammates")}</div>
{_t("create_space|private_space")}
<div>{_t("create_space|private_space_description")}</div>
</AccessibleButton>
</div>
);
Expand Down Expand Up @@ -550,7 +544,7 @@ const SpaceSetupPrivateInvite: React.FC<{
if (failedUsers.length > 0) {
logger.log("Failed to invite users to space: ", result);
setError(
_t("Failed to invite the following users to your space: %(csvUsers)s", {
_t("create_space|failed_invite_users", {
csvUsers: failedUsers.join(", "),
}),
);
Expand All @@ -568,18 +562,16 @@ const SpaceSetupPrivateInvite: React.FC<{
ev.preventDefault();
onFinished();
};
let buttonLabel = _t("Skip for now");
let buttonLabel = _t("create_space|skip_action");
if (emailAddresses.some((name) => name.trim())) {
onClick = onNextClick;
buttonLabel = busy ? _t("Inviting…") : _t("action|continue");
buttonLabel = busy ? _t("create_space|inviting_users") : _t("action|continue");
}

return (
<div className="mx_SpaceRoomView_inviteTeammates">
<h1>{_t("Invite your teammates")}</h1>
<div className="mx_SpaceRoomView_description">
{_t("Make sure the right people have access. You can invite more later.")}
</div>
<h1>{_t("create_space|invite_teammates_heading")}</h1>
<div className="mx_SpaceRoomView_description">{_t("create_space|invite_teammates_description")}</div>

{error && <div className="mx_SpaceRoomView_errorText">{error}</div>}
<form onSubmit={onClick} id="mx_SpaceSetupPrivateInvite">
Expand All @@ -591,7 +583,7 @@ const SpaceSetupPrivateInvite: React.FC<{
className="mx_SpaceRoomView_inviteTeammates_inviteDialogButton"
onClick={() => showRoomInviteDialog(space.roomId)}
>
{_t("Invite by username")}
{_t("create_space|invite_teammates_by_username")}
</AccessibleButton>
</div>

Expand Down Expand Up @@ -701,14 +693,14 @@ export default class SpaceRoomView extends React.PureComponent<IProps, IState> {
return (
<SpaceSetupFirstRooms
space={this.props.space}
title={_t("What are some things you want to discuss in %(spaceName)s?", {
title={_t("create_space|setup_rooms_community_heading", {
spaceName: this.props.justCreatedOpts?.createOpts?.name || this.props.space.name,
})}
description={
<>
{_t("Let's create a room for each of them.")}
{_t("create_space|setup_rooms_community_description")}
<br />
{_t("You can add more later too, including already existing ones.")}
{_t("create_space|setup_rooms_description")}
</>
}
onFinished={(firstRoomId: string) => this.setState({ phase: Phase.PublicShare, firstRoomId })}
Expand Down Expand Up @@ -745,12 +737,12 @@ export default class SpaceRoomView extends React.PureComponent<IProps, IState> {
return (
<SpaceSetupFirstRooms
space={this.props.space}
title={_t("What projects are your team working on?")}
title={_t("create_space|setup_rooms_private_heading")}
description={
<>
{_t("We'll create rooms for each of them.")}
{_t("create_space|setup_rooms_private_description")}
<br />
{_t("You can add more later too, including already existing ones.")}
{_t("create_space|setup_rooms_description")}
</>
}
onFinished={(firstRoomId: string) => this.setState({ phase: Phase.PrivateInvite, firstRoomId })}
Expand Down
27 changes: 12 additions & 15 deletions src/components/structures/ThreadPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ export const ThreadPanelHeader: React.FC<{
const [menuDisplayed, button, openMenu, closeMenu] = useContextMenu<HTMLElement>();
const options: readonly ThreadPanelHeaderOption[] = [
{
label: _t("All threads"),
description: _t("Shows all threads from current room"),
label: _t("threads|all_threads"),
description: _t("threads|all_threads_description"),
key: ThreadFilterType.All,
},
{
label: _t("My threads"),
description: _t("Shows all threads you've participated in"),
label: _t("threads|my_threads"),
description: _t("threads|my_threads_description"),
key: ThreadFilterType.My,
},
];
Expand Down Expand Up @@ -125,7 +125,7 @@ export const ThreadPanelHeader: React.FC<{
PosthogTrackers.trackInteraction("WebRightPanelThreadPanelFilterDropdown", ev);
}}
>
{`${_t("Show:")} ${value?.label}`}
{`${_t("threads|show_thread_filter")} ${value?.label}`}
</ContextMenuButton>
{contextMenu}
</>
Expand All @@ -146,17 +146,14 @@ const EmptyThread: React.FC<EmptyThreadIProps> = ({ hasThreads, filterOption, sh
body = (
<>
<p>
{_t(
"Reply to an ongoing thread or use “%(replyInThread)s” when hovering over a message to start a new one.",
{
replyInThread: _t("Reply in thread"),
},
)}
{_t("threads|empty_has_threads_tip", {
replyInThread: _t("Reply in thread"),
})}
</p>
<p>
{/* Always display that paragraph to prevent layout shift when hiding the button */}
{filterOption === ThreadFilterType.My ? (
<button onClick={showAllThreadsCallback}>{_t("Show all threads")}</button>
<button onClick={showAllThreadsCallback}>{_t("threads|show_all_threads")}</button>
) : (
<>&nbsp;</>
)}
Expand All @@ -166,10 +163,10 @@ const EmptyThread: React.FC<EmptyThreadIProps> = ({ hasThreads, filterOption, sh
} else {
body = (
<>
<p>{_t("Threads help keep your conversations on-topic and easy to track.")}</p>
<p>{_t("threads|empty_explainer")}</p>
<p className="mx_ThreadPanel_empty_tip">
{_t(
"<b>Tip:</b> Use “%(replyInThread)s” when hovering over a message.",
"threads|empty_tip",
{
replyInThread: _t("Reply in thread"),
},
Expand All @@ -185,7 +182,7 @@ const EmptyThread: React.FC<EmptyThreadIProps> = ({ hasThreads, filterOption, sh
return (
<aside className="mx_ThreadPanel_empty">
<div className="mx_ThreadPanel_largeIcon" />
<h2>{_t("Keep discussions organised with threads")}</h2>
<h2>{_t("threads|empty_heading")}</h2>
{body}
</aside>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const DeveloperToolsOption: React.FC<Props> = ({ onFinished, roomId }) =>
);
onFinished();
}}
label={_t("Developer tools")}
label={_t("devtools|title")}
iconClassName="mx_IconizedContextMenu_developerTools"
/>
);
Expand Down
4 changes: 3 additions & 1 deletion src/components/views/context_menus/IconizedContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export const IconizedContextMenuCheckbox: React.FC<ICheckboxProps> = ({
}) => {
let marker: JSX.Element;
if (words) {
marker = <span className="mx_IconizedContextMenu_activeText">{active ? _t("On") : _t("Off")}</span>;
marker = (
<span className="mx_IconizedContextMenu_activeText">{active ? _t("common|on") : _t("common|off")}</span>
);
} else {
marker = (
<span
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/dialogs/UserSettingsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
tabs.push(
new Tab(
UserTab.Keyboard,
_td("Keyboard"),
_td("settings|keyboard|title"),
"mx_UserSettingsDialog_keyboardIcon",
<KeyboardUserSettingsTab />,
"UserSettingsKeyboard",
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/location/MapError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const MapError: React.FC<MapErrorProps> = ({ error, isMinimised, classNam
>
<WarningBadge className="mx_MapError_icon" />
<Heading className="mx_MapError_heading" size="3">
{_t("Unable to load map")}
{_t("location_sharing|failed_load_map")}
</Heading>
<p className="mx_MapError_message">{getLocationShareErrorMessage(error)}</p>
{onFinished && (
Expand Down
Loading

0 comments on commit 5cb8cbd

Please sign in to comment.