invite-user-modal: Internationalize custom time unit options.

Prep for using these values other modals, specifically the
deactivate realm modal.
This commit is contained in:
Lauryn Menard 2024-06-26 20:27:16 +02:00 committed by Tim Abbott
parent 68dc914b6e
commit cc1a3eeec1
4 changed files with 26 additions and 3 deletions

View File

@ -167,6 +167,11 @@ IGNORED_PHRASES = [
r"deactivated", r"deactivated",
# This is a reference to a setting/secret and should be lowercase. # This is a reference to a setting/secret and should be lowercase.
r"zulip_org_id", r"zulip_org_id",
# These are custom time unit options for modal dropdowns
r"minutes",
r"hours",
r"days",
r"weeks",
] ]
# Sort regexes in descending order of their lengths. As a result, the # Sort regexes in descending order of their lengths. As a result, the

View File

@ -351,14 +351,13 @@ function open_invite_user_modal(e: JQuery.ClickEvent<Document, undefined>): void
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
const time_unit_choices = ["minutes", "hours", "days", "weeks"];
const html_body = render_invite_user_modal({ const html_body = render_invite_user_modal({
is_admin: current_user.is_admin, is_admin: current_user.is_admin,
is_owner: current_user.is_owner, is_owner: current_user.is_owner,
development_environment: page_params.development_environment, development_environment: page_params.development_environment,
invite_as_options: settings_config.user_role_values, invite_as_options: settings_config.user_role_values,
expires_in_options: settings_config.expires_in_values, expires_in_options: settings_config.expires_in_values,
time_choices: time_unit_choices, time_choices: settings_config.custom_time_unit_values,
show_select_default_streams_option: stream_data.get_default_stream_ids().length !== 0, show_select_default_streams_option: stream_data.get_default_stream_ids().length !== 0,
user_has_email_set: !settings_data.user_email_not_configured(), user_has_email_set: !settings_data.user_email_not_configured(),
can_subscribe_other_users: settings_data.user_can_subscribe_other_users(), can_subscribe_other_users: settings_data.user_can_subscribe_other_users(),

View File

@ -545,6 +545,25 @@ export const expires_in_values = {
}, },
}; };
export const custom_time_unit_values = {
minutes: {
name: "minutes",
description: $t({defaultMessage: "minutes"}),
},
hours: {
name: "hours",
description: $t({defaultMessage: "hours"}),
},
days: {
name: "days",
description: $t({defaultMessage: "days"}),
},
weeks: {
name: "weeks",
description: $t({defaultMessage: "weeks"}),
},
};
const user_role_array = Object.values(user_role_values); const user_role_array = Object.values(user_role_values);
export const user_role_map = new Map(user_role_array.map((role) => [role.code, role.description])); export const user_role_map = new Map(user_role_array.map((role) => [role.code, role.description]));

View File

@ -46,7 +46,7 @@
<input type="text" autocomplete="off" name="custom-expiration-time" id="custom-expiration-time-input" class="custom-expiration-time inline-block" value="" maxlength="3"/> <input type="text" autocomplete="off" name="custom-expiration-time" id="custom-expiration-time-input" class="custom-expiration-time inline-block" value="" maxlength="3"/>
<select class="custom-expiration-time invite-user-select modal_select bootstrap-focus-style" id="custom-expiration-time-unit"> <select class="custom-expiration-time invite-user-select modal_select bootstrap-focus-style" id="custom-expiration-time-unit">
{{#each time_choices}} {{#each time_choices}}
<option name="custom_time_choice" class="custom_time_choice" value="{{this}}">{{this}}</option> <option name="custom_time_choice" class="custom_time_choice" value="{{this.name}}">{{this.description}}</option>
{{/each}} {{/each}}
</select> </select>
<p id="custom_expires_on"></p> <p id="custom_expires_on"></p>