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

Migrate more strings to translation keys #11530

Merged
merged 3 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 37 additions & 39 deletions src/SlashCommands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const Commands = [
new Command({
command: "spoiler",
args: "<message>",
description: _td("Sends the given message as a spoiler"),
description: _td("slash_command|spoiler"),
runFn: function (cli, roomId, threadId, message = "") {
return successSync(ContentHelpers.makeHtmlMessage(message, `<span data-mx-spoiler>${message}</span>`));
},
Expand All @@ -78,7 +78,7 @@ export const Commands = [
new Command({
command: "shrug",
args: "<message>",
description: _td("Prepends ¯\\_(ツ)_/¯ to a plain-text message"),
description: _td("slash_command|shrug"),
runFn: function (cli, roomId, threadId, args) {
let message = "¯\\_(ツ)_/¯";
if (args) {
Expand All @@ -91,7 +91,7 @@ export const Commands = [
new Command({
command: "tableflip",
args: "<message>",
description: _td("Prepends (╯°□°)╯︵ ┻━┻ to a plain-text message"),
description: _td("slash_command|tableflip"),
runFn: function (cli, roomId, threadId, args) {
let message = "(╯°□°)╯︵ ┻━┻";
if (args) {
Expand All @@ -104,7 +104,7 @@ export const Commands = [
new Command({
command: "unflip",
args: "<message>",
description: _td("Prepends ┬──┬ ノ( ゜-゜ノ) to a plain-text message"),
description: _td("slash_command|unflip"),
runFn: function (cli, roomId, threadId, args) {
let message = "┬──┬ ノ( ゜-゜ノ)";
if (args) {
Expand All @@ -117,7 +117,7 @@ export const Commands = [
new Command({
command: "lenny",
args: "<message>",
description: _td("Prepends ( ͡° ͜ʖ ͡°) to a plain-text message"),
description: _td("slash_command|lenny"),
runFn: function (cli, roomId, threadId, args) {
let message = "( ͡° ͜ʖ ͡°)";
if (args) {
Expand All @@ -130,7 +130,7 @@ export const Commands = [
new Command({
command: "plain",
args: "<message>",
description: _td("Sends a message as plain text, without interpreting it as markdown"),
description: _td("slash_command|plain"),
runFn: function (cli, roomId, threadId, messages = "") {
return successSync(ContentHelpers.makeTextMessage(messages));
},
Expand All @@ -139,7 +139,7 @@ export const Commands = [
new Command({
command: "html",
args: "<message>",
description: _td("Sends a message as html, without interpreting it as markdown"),
description: _td("slash_command|html"),
runFn: function (cli, roomId, threadId, messages = "") {
return successSync(ContentHelpers.makeHtmlMessage(messages, messages));
},
Expand All @@ -148,15 +148,13 @@ export const Commands = [
new Command({
command: "upgraderoom",
args: "<new_version>",
description: _td("Upgrades a room to a new version"),
description: _td("slash_command|upgraderoom"),
isEnabled: (cli) => !isCurrentLocalRoom(cli),
runFn: function (cli, roomId, threadId, args) {
if (args) {
const room = cli.getRoom(roomId);
if (!room?.currentState.mayClientSendStateEvent("m.room.tombstone", cli)) {
return reject(
new UserFriendlyError("You do not have the required permissions to use this command."),
);
return reject(new UserFriendlyError("slash_command|upgraderoom_permission_error"));
}

const { finished } = Modal.createDialog(
Expand All @@ -182,18 +180,18 @@ export const Commands = [
new Command({
command: "jumptodate",
args: "<YYYY-MM-DD>",
description: _td("Jump to the given date in the timeline"),
description: _td("slash_command|jumptodate"),
isEnabled: () => SettingsStore.getValue("feature_jump_to_date"),
runFn: function (cli, roomId, threadId, args) {
if (args) {
return success(
(async (): Promise<void> => {
const unixTimestamp = Date.parse(args);
if (!unixTimestamp) {
throw new UserFriendlyError(
"We were unable to understand the given date (%(inputDate)s). Try using the format YYYY-MM-DD.",
{ inputDate: args, cause: undefined },
);
throw new UserFriendlyError("slash_command|jumptodate_invalid_input", {
inputDate: args,
cause: undefined,
});
}

const { event_id: eventId, origin_server_ts: originServerTs } = await cli.timestampToEvent(
Expand Down Expand Up @@ -223,7 +221,7 @@ export const Commands = [
new Command({
command: "nick",
args: "<display_name>",
description: _td("Changes your display nickname"),
description: _td("slash_command|nick"),
runFn: function (cli, roomId, threadId, args) {
if (args) {
return success(cli.setDisplayName(args));
Expand All @@ -237,7 +235,7 @@ export const Commands = [
command: "myroomnick",
aliases: ["roomnick"],
args: "<display_name>",
description: _td("Changes your display nickname in the current room only"),
description: _td("slash_command|myroomnick"),
isEnabled: (cli) => !isCurrentLocalRoom(cli),
runFn: function (cli, roomId, threadId, args) {
if (args) {
Expand All @@ -256,7 +254,7 @@ export const Commands = [
new Command({
command: "roomavatar",
args: "[<mxc_url>]",
description: _td("Changes the avatar of the current room"),
description: _td("slash_command|roomavatar"),
isEnabled: (cli) => !isCurrentLocalRoom(cli),
runFn: function (cli, roomId, threadId, args) {
let promise = Promise.resolve(args ?? null);
Expand All @@ -277,7 +275,7 @@ export const Commands = [
new Command({
command: "myroomavatar",
args: "[<mxc_url>]",
description: _td("Changes your profile picture in this current room only"),
description: _td("slash_command|myroomavatar"),
isEnabled: (cli) => !isCurrentLocalRoom(cli),
runFn: function (cli, roomId, threadId, args) {
const room = cli.getRoom(roomId);
Expand Down Expand Up @@ -306,7 +304,7 @@ export const Commands = [
new Command({
command: "myavatar",
args: "[<mxc_url>]",
description: _td("Changes your profile picture in all rooms"),
description: _td("slash_command|myavatar"),
runFn: function (cli, roomId, threadId, args) {
let promise = Promise.resolve(args ?? null);
if (!args) {
Expand All @@ -326,7 +324,7 @@ export const Commands = [
new Command({
command: "topic",
args: "[<topic>]",
description: _td("Gets or sets the room topic"),
description: _td("slash_command|topic"),
isEnabled: (cli) => !isCurrentLocalRoom(cli),
runFn: function (cli, roomId, threadId, args) {
if (args) {
Expand All @@ -336,7 +334,7 @@ export const Commands = [
const room = cli.getRoom(roomId);
if (!room) {
return reject(
new UserFriendlyError("Failed to get room topic: Unable to find room (%(roomId)s", {
new UserFriendlyError("slash_command|topic_room_error", {
roomId,
cause: undefined,
}),
Expand All @@ -346,7 +344,7 @@ export const Commands = [
const content = room.currentState.getStateEvents("m.room.topic", "")?.getContent<MRoomTopicEventContent>();
const topic = !!content
? ContentHelpers.parseTopicContent(content)
: { text: _t("This room has no topic.") };
: { text: _t("slash_command|topic_none") };

const body = topicToHtml(topic.text, topic.html, undefined, true);

Expand All @@ -364,7 +362,7 @@ export const Commands = [
new Command({
command: "roomname",
args: "<name>",
description: _td("Sets the room name"),
description: _td("slash_command|roomname"),
isEnabled: (cli) => !isCurrentLocalRoom(cli),
runFn: function (cli, roomId, threadId, args) {
if (args) {
Expand All @@ -378,7 +376,7 @@ export const Commands = [
new Command({
command: "invite",
args: "<user-id> [<reason>]",
description: _td("Invites user with given id to current room"),
description: _td("slash_command|invite"),
analyticsName: "Invite",
isEnabled: (cli) => !isCurrentLocalRoom(cli) && shouldShowComponent(UIComponent.InviteUsers),
runFn: function (cli, roomId, threadId, args) {
Expand Down Expand Up @@ -497,7 +495,7 @@ export const Commands = [
command: "remove",
aliases: ["kick"],
args: "<user-id> [reason]",
description: _td("Removes user with given id from this room"),
description: _td("slash_command|remove"),
isEnabled: (cli) => !isCurrentLocalRoom(cli),
runFn: function (cli, roomId, threadId, args) {
if (args) {
Expand All @@ -514,7 +512,7 @@ export const Commands = [
new Command({
command: "ban",
args: "<user-id> [reason]",
description: _td("Bans user with given id"),
description: _td("slash_command|ban"),
isEnabled: (cli) => !isCurrentLocalRoom(cli),
runFn: function (cli, roomId, threadId, args) {
if (args) {
Expand All @@ -531,7 +529,7 @@ export const Commands = [
new Command({
command: "unban",
args: "<user-id>",
description: _td("Unbans user with given ID"),
description: _td("slash_command|unban"),
isEnabled: (cli) => !isCurrentLocalRoom(cli),
runFn: function (cli, roomId, threadId, args) {
if (args) {
Expand All @@ -549,7 +547,7 @@ export const Commands = [
new Command({
command: "ignore",
args: "<user-id>",
description: _td("Ignores a user, hiding their messages from you"),
description: _td("slash_command|ignore"),
runFn: function (cli, roomId, threadId, args) {
if (args) {
const matches = args.match(/^(@[^:]+:\S+)$/);
Expand Down Expand Up @@ -578,7 +576,7 @@ export const Commands = [
new Command({
command: "unignore",
args: "<user-id>",
description: _td("Stops ignoring a user, showing their messages going forward"),
description: _td("slash_command|unignore"),
runFn: function (cli, roomId, threadId, args) {
if (args) {
const matches = args.match(/(^@[^:]+:\S+$)/);
Expand Down Expand Up @@ -609,7 +607,7 @@ export const Commands = [
deop,
new Command({
command: "devtools",
description: _td("Opens the Developer Tools dialog"),
description: _td("slash_command|devtools"),
runFn: function (cli, roomId, threadRootId) {
Modal.createDialog(DevtoolsDialog, { roomId, threadRootId }, "mx_DevtoolsDialog_wrapper");
return success();
Expand All @@ -619,7 +617,7 @@ export const Commands = [
new Command({
command: "addwidget",
args: "<url | embed code | Jitsi url>",
description: _td("Adds a custom widget by URL to the room"),
description: _td("slash_command|addwidget"),
isEnabled: (cli) =>
SettingsStore.getValue(UIFeature.Widgets) &&
shouldShowComponent(UIComponent.AddIntegrations) &&
Expand Down Expand Up @@ -794,7 +792,7 @@ export const Commands = [
}),
new Command({
command: "rainbow",
description: _td("Sends the given message coloured as a rainbow"),
description: _td("slash_command|rainbow"),
args: "<message>",
runFn: function (cli, roomId, threadId, args) {
if (!args) return reject(this.getUsage());
Expand All @@ -804,7 +802,7 @@ export const Commands = [
}),
new Command({
command: "rainbowme",
description: _td("Sends the given emote coloured as a rainbow"),
description: _td("slash_command|rainbowme"),
args: "<message>",
runFn: function (cli, roomId, threadId, args) {
if (!args) return reject(this.getUsage());
Expand All @@ -814,7 +812,7 @@ export const Commands = [
}),
new Command({
command: "help",
description: _td("Displays list of commands with usages and descriptions"),
description: _td("slash_command|help"),
runFn: function () {
Modal.createDialog(SlashCommandHelpDialog);
return success();
Expand All @@ -823,7 +821,7 @@ export const Commands = [
}),
new Command({
command: "whois",
description: _td("Displays information about a user"),
description: _td("slash_command|whois"),
args: "<user-id>",
isEnabled: (cli) => !isCurrentLocalRoom(cli),
runFn: function (cli, roomId, threadId, userId) {
Expand All @@ -844,7 +842,7 @@ export const Commands = [
new Command({
command: "rageshake",
aliases: ["bugreport"],
description: _td("Send a bug report with logs"),
description: _td("slash_command|rageshake"),
isEnabled: () => !!SdkConfig.get().bug_report_endpoint_url,
args: "<description>",
runFn: function (cli, roomId, threadId, args) {
Expand Down Expand Up @@ -916,7 +914,7 @@ export const Commands = [
}),
new Command({
command: "msg",
description: _td("Sends a message to the given user"),
description: _td("slash_command|msg"),
args: "<user-id> [<message>]",
runFn: function (cli, roomId, threadId, args) {
if (args) {
Expand Down
Loading
Loading