Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
i18n: Add new markup for lazy translation of giphy ratings.
Daniil Fadeevd606f5ba4269
diff --git a/tools/lib/capitalization.py b/tools/lib/capitalization.pyindex 5fdd05bc8e6..543bba4aebf 100644--- a/tools/lib/capitalization.py+++ b/tools/lib/capitalization.py@@ -106,6 +106,12 @@ IGNORED_PHRASES = [r"your-organization-url",# Used in invite modalr"or",+ # Used in GIPHY integration setting. GIFs Rating.+ r"rated Y",+ r"rated G",+ r"rated PG",+ r"rated PG13",+ r"rated R",# Used in GIPHY popover.r"GIFs",r"GIPHY",diff --git a/zerver/lib/events.py b/zerver/lib/events.pyindex 4483db00a96..aff58aa128a 100644--- a/zerver/lib/events.py+++ b/zerver/lib/events.py@@ -315,7 +315,7 @@ def fetch_initial_state_data(state["server_avatar_changes_disabled"] = settings.AVATAR_CHANGES_DISABLEDstate["server_name_changes_disabled"] = settings.NAME_CHANGES_DISABLEDstate["server_web_public_streams_enabled"] = settings.WEB_PUBLIC_STREAMS_ENABLED- state["giphy_rating_options"] = realm.GIPHY_RATING_OPTIONS+ state["giphy_rating_options"] = realm.get_giphy_rating_options()state["server_emoji_data_url"] = emoji.data_url()diff --git a/zerver/models.py b/zerver/models.pyindex 3cdcedba764..882e486a720 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -650,34 +650,43 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stubdefault=VIDEO_CHAT_PROVIDERS["jitsi_meet"]["id"])+ # Please access this via get_giphy_rating_options.GIPHY_RATING_OPTIONS = {"disabled": {- "name": "GIPHY integration disabled",+ "name": gettext_lazy("GIPHY integration disabled"),"id": 0,},# Source: https://github.com/Giphy/giphy-js/blob/master/packages/fetch-api/README.md#shared-options"y": {- "name": "Allow GIFs rated Y (Very young audience)",+ "name": gettext_lazy("Allow GIFs rated Y (Very young audience)"),"id": 1,},"g": {- "name": "Allow GIFs rated G (General audience)",+ "name": gettext_lazy("Allow GIFs rated G (General audience)"),"id": 2,},"pg": {- "name": "Allow GIFs rated PG (Parental guidance)",+ "name": gettext_lazy("Allow GIFs rated PG (Parental guidance)"),"id": 3,},"pg-13": {- "name": "Allow GIFs rated PG13 (Parental guidance - under 13)",+ "name": gettext_lazy("Allow GIFs rated PG13 (Parental guidance - under 13)"),"id": 4,},"r": {- "name": "Allow GIFs rated R (Restricted)",+ "name": gettext_lazy("Allow GIFs rated R (Restricted)"),"id": 5,},}+ def get_giphy_rating_options(self) -> Dict[str, Dict[str, object]]:+ """Wrapper function for GIPHY_RATING_OPTIONS that ensures evaluation+ of the lazily evaluated `name` field without modifying the original."""+ return {+ rating_type: {"name": str(rating["name"]), "id": rating["id"]}+ for rating_type, rating in self.GIPHY_RATING_OPTIONS.items()+ }+# maximum rating of the GIFs that will be retrieved from GIPHYgiphy_rating = models.PositiveSmallIntegerField(default=GIPHY_RATING_OPTIONS["g"]["id"])