From cc1a3eeec18dd7c31807b85fa0458b1477b00096 Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Wed, 26 Jun 2024 20:27:16 +0200 Subject: [PATCH] invite-user-modal: Internationalize custom time unit options. Prep for using these values other modals, specifically the deactivate realm modal. --- tools/lib/capitalization.py | 5 +++++ web/src/invite.ts | 3 +-- web/src/settings_config.ts | 19 +++++++++++++++++++ web/templates/invite_user_modal.hbs | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/tools/lib/capitalization.py b/tools/lib/capitalization.py index 5ce16f63c0..5d4394a65d 100644 --- a/tools/lib/capitalization.py +++ b/tools/lib/capitalization.py @@ -167,6 +167,11 @@ IGNORED_PHRASES = [ r"deactivated", # This is a reference to a setting/secret and should be lowercase. 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 diff --git a/web/src/invite.ts b/web/src/invite.ts index bbe180eee3..b022d63ae7 100644 --- a/web/src/invite.ts +++ b/web/src/invite.ts @@ -351,14 +351,13 @@ function open_invite_user_modal(e: JQuery.ClickEvent): void e.stopPropagation(); e.preventDefault(); - const time_unit_choices = ["minutes", "hours", "days", "weeks"]; const html_body = render_invite_user_modal({ is_admin: current_user.is_admin, is_owner: current_user.is_owner, development_environment: page_params.development_environment, invite_as_options: settings_config.user_role_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, user_has_email_set: !settings_data.user_email_not_configured(), can_subscribe_other_users: settings_data.user_can_subscribe_other_users(), diff --git a/web/src/settings_config.ts b/web/src/settings_config.ts index 9ab85e2144..453926a16b 100644 --- a/web/src/settings_config.ts +++ b/web/src/settings_config.ts @@ -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); export const user_role_map = new Map(user_role_array.map((role) => [role.code, role.description])); diff --git a/web/templates/invite_user_modal.hbs b/web/templates/invite_user_modal.hbs index c0c8806115..fdcade3f55 100644 --- a/web/templates/invite_user_modal.hbs +++ b/web/templates/invite_user_modal.hbs @@ -46,7 +46,7 @@