element-web/src/Roles.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.2 KiB
TypeScript
Raw Normal View History

/*
Copyright 2017 Vector Creations Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { _t } from "./languageHandler";
export function levelRoleMap(usersDefault: number): Record<number | "undefined", string> {
2017-05-25 19:17:37 +03:00
return {
Port more strings to translation keys (#11474) * Port composer formatting strings to translation keys ``` replace "Bold" "composer|format_bold" replace "Italic" "composer|format_italic" replace "Underline" "composer|format_underline" replace "Strikethrough" "composer|format_strikethrough" replace "Bulleted list" "composer|format_unordered_list" replace "Numbered list" "composer|format_ordered_list" replace "Indent increase" "composer|format_increase_indent" replace "Indent decrease" "composer|format_decrease_indent" replace "Code" "composer|format_inline_code" replace "Code block" "composer|format_code_block" replace "Link" "composer|format_link" copy "composer|format_bold" "Bold" copy "composer|format_link" "Link" copy "composer|format_inline_code" "Code" ``` * Port role strings to translation keys ``` copy "Default" "power_level|default" copy "Restricted" "power_level|restricted" copy "Moderator" "power_level|moderator" copy "Admin" "power_level|admin" ``` * Port bug reporting strings to translation keys ``` replace "If you've submitted a bug via GitHub, debug logs can help us track down the problem. " "bug_reporting|introduction" replace "Debug logs contain application usage data including your username, the IDs or aliases of the rooms you have visited, which UI elements you last interacted with, and the usernames of other users. They do not contain messages." "bug_reporting|description" copy "To report a Matrix-related security issue, please read the Matrix.org <a>Security Disclosure Policy</a>." "bug_reporting|matrix_security_issue" replace "Submit debug logs" "bug_reporting|submit_debug_logs" replace "Bug reporting" "bug_reporting|title" replace "If there is additional context that would help in analysing the issue, such as what you were doing at the time, room IDs, user IDs, etc., please include those things here." "bug_reporting|additional_context" replace "Send logs" "bug_reporting|send_logs" replace "GitHub issue" "bug_reporting|github_issue" replace "Download logs" "bug_reporting|download_logs" copy "Before submitting logs, you must <a>create a GitHub issue</a> to describe your problem." "bug_reporting|before_submitting" ``` * i18n * Port time duration strings to translation keys ``` replace "%(hours)sh %(minutes)sm %(seconds)ss left" "time|hours_minutes_seconds_left" replace "%(minutes)sm %(seconds)ss left" "time|minutes_seconds_left" replace "%(seconds)ss left" "time|seconds_left" replace "%(date)s at %(time)s" "time|date_at_time" replace "%(value)sd" "time|short_days" replace "%(value)sh" "time|short_hours" replace "%(value)sm" "time|short_minutes" replace "%(value)ss" "time|short_seconds" replace "%(days)sd %(hours)sh %(minutes)sm %(seconds)ss" "time|short_days_hours_minutes_seconds" replace "%(hours)sh %(minutes)sm %(seconds)ss" "time|short_hours_minutes_seconds" replace "%(minutes)sm %(seconds)ss" "time|short_minutes_seconds" ``` * i18n
2023-08-31 10:35:34 +03:00
undefined: _t("power_level|default"),
0: _t("power_level|restricted"),
[usersDefault]: _t("power_level|default"),
50: _t("power_level|moderator"),
100: _t("power_level|admin"),
2017-05-25 19:17:37 +03:00
};
}
export function textualPowerLevel(level: number, usersDefault: number): string {
const LEVEL_ROLE_MAP = levelRoleMap(usersDefault);
if (LEVEL_ROLE_MAP[level]) {
2019-11-14 18:58:56 +03:00
return LEVEL_ROLE_MAP[level];
} else {
return _t("power_level|custom", { level });
}
}