From 01d3bf64a5e3511ee8218bb0aab817b736d21e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sabri=20=C3=9Cnal?= <161761531+yakushabb@users.noreply.github.com> Date: Mon, 1 Apr 2024 17:26:28 +0300 Subject: [PATCH] Translation related patches (#108) * appdata: `translate=no` properties It appears that the appstream project no longer supports `translatable=no` properties, and gettext extract the `translatable=no` marked strings as translatable. I opened an issue to inform about the situation, but `translatable=no` properties are not accepted by developers. You can find the issue here: `https://github.com/ximion/appstream/issues/623` **Please test your script or string extraction process before merging this PR.** > In MetaInfo files, each individual paragraph of a description > (or enumerated entry) is translated individually, however, > you can only exclude the complete block from being translated > by adding `translate="no"` to the description element. Source: https://freedesktop.org/software/appstream/docs/sect-Quickstart-Translation.html * appdata: Add developer ID Flathub requires a developer tag and developer ID. > A developer tag with a name child tag must be present. Only one developer tag is allowed and the name tag also must be present only once in untranslated form. ``` Developer name ``` Source: https://docs.flathub.org/docs/for-app-authors/metainfo-guidelines/#name-summary-and-developer-name * i18n: Use C_ alias for pgettext That way it's easy to catch a translatable string. --- data/io.github.amit9838.mousam.appdata.xml.in | 25 ++++++++++-------- src/frontendForecast.py | 2 +- src/frontendHourlyDetails.py | 6 ++--- src/mousam.py | 8 +++--- src/weatherData.py | 26 +++++++++---------- update-pot | 2 +- 6 files changed, 36 insertions(+), 33 deletions(-) diff --git a/data/io.github.amit9838.mousam.appdata.xml.in b/data/io.github.amit9838.mousam.appdata.xml.in index c13007a..9f08f07 100644 --- a/data/io.github.amit9838.mousam.appdata.xml.in +++ b/data/io.github.amit9838.mousam.appdata.xml.in @@ -43,6 +43,9 @@ https://github.com/amit9838/mousam/tree/master/po https://github.com/amit9838/mousam Amit Chaudhary + + Amit Chaudhary + pointing touch @@ -56,7 +59,7 @@ - +

What's New

  • Dynamic background is back again, app background changes based on current weather condition.
  • @@ -78,7 +81,7 @@ - +

    Bug fixes

    • Bug fixes related to build
    • @@ -91,7 +94,7 @@ - +

      Bug fixes

      • Fix bug where some locations dosen't provide valid co-ordinates
      • @@ -100,7 +103,7 @@ - +

        What's New

        • Introducing a new design with an entirely new app experience.
        • @@ -124,7 +127,7 @@ - +
          • Adds air-pollution info
          • Adds Snowfall summary
          • @@ -136,7 +139,7 @@ - +
            • Adds sunset/sunrise info
            • Add and remove city more quickly
            • @@ -147,7 +150,7 @@ - +
              • Adds 5 days forecast
              • Adds rain summary (rain quantity)
              • @@ -158,7 +161,7 @@ - +
                • Show today and tomorrow forecasts
                • Option:Use Imerial, Metric systems
                • @@ -173,7 +176,7 @@ - +
                  • Use full country name.
                  • Fix units.
                  • @@ -183,7 +186,7 @@ - +

                    What's New

                    • Option:Use Custom api-key.
                    • @@ -196,7 +199,7 @@ - +

                      New features and updates

                      • Use dynamic gradient backgrounds based on current weather.
                      • diff --git a/src/frontendForecast.py b/src/frontendForecast.py index e4e004d..b90f99f 100644 --- a/src/frontendForecast.py +++ b/src/frontendForecast.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta import gi from gi.repository import Gtk -from gettext import gettext as _ +from gettext import gettext as _, pgettext as C_ from .constants import icons from .utils import is_dynamic_bg_enabled diff --git a/src/frontendHourlyDetails.py b/src/frontendHourlyDetails.py index 562d7a7..64a55cf 100644 --- a/src/frontendHourlyDetails.py +++ b/src/frontendHourlyDetails.py @@ -92,7 +92,7 @@ def create_stack_page(self, page_name): info_grid = Gtk.Grid(margin_start=20, margin_top=10) page_grid.attach(info_grid, 0, 1, 1, 1) - desc_label = Gtk.Label(label=gettext.pgettext("wind", "Day High"), halign=Gtk.Align.START) + desc_label = Gtk.Label(label=C_("wind", "Day High"), halign=Gtk.Align.START) desc_label.set_css_classes(["text-4", "light-2", "bold-2"]) info_grid.attach(desc_label, 0, 0, 3, 1) @@ -108,7 +108,7 @@ def create_stack_page(self, page_name): # Hourly Page if page_name == "hourly": - desc_label.set_text(gettext.pgettext("temperature","Day Max")) + desc_label.set_text(C_("temperature","Day Max")) val_label.set_text(str(max(hourly_data.temperature_2m.get("data"))) + "°") unit_label.set_text("") @@ -123,7 +123,7 @@ def create_stack_page(self, page_name): unit = "inch" if page_name == "prec": - desc_label.set_text(gettext.pgettext("precipitation","Day High")) + desc_label.set_text(C_("precipitation","Day High")) val_label.set_text(f"{max_prec:.2f}") unit_label.set_text(unit) diff --git a/src/mousam.py b/src/mousam.py index 929bd9e..491d040 100644 --- a/src/mousam.py +++ b/src/mousam.py @@ -274,8 +274,8 @@ def get_weather(self, reload_type=None, title=""): main_val_unit="", desc=cw_data.surface_pressure.get("unit"), sub_desc_heading=cw_data.surface_pressure.get("level_str"), - text_up=gettext.pgettext("pressure card", "High"), - text_low=gettext.pgettext("pressure card", "Low"), + text_up=C_("pressure card", "High"), + text_low=C_("pressure card", "Low"), ) widget_grid.attach(card_obj.card, 0, 1, 1, 1) @@ -284,8 +284,8 @@ def get_weather(self, reload_type=None, title=""): title="UV Index", main_val=cw_data.uv_index.get("data"), desc=cw_data.uv_index.get("level_str"), - text_up=gettext.pgettext("uvindex card","High"), - text_low=gettext.pgettext("uvindex card", "Low"), + text_up=C_("uvindex card","High"), + text_low=C_("uvindex card", "Low"), ) widget_grid.attach(card_obj.card, 1, 1, 1, 1) diff --git a/src/weatherData.py b/src/weatherData.py index c4b4e50..2865775 100644 --- a/src/weatherData.py +++ b/src/weatherData.py @@ -115,33 +115,33 @@ def classify_aqi(aqi_value): def classify_uv_index(uv_index): if uv_index <= 2: - return gettext.pgettext("uvindex", "Low") + return C_("uvindex", "Low") elif uv_index <= 5: - return gettext.pgettext("uvindex", "Moderate") + return C_("uvindex", "Moderate") elif uv_index <= 7: - return gettext.pgettext("uvindex", "High") + return C_("uvindex", "High") elif uv_index <= 10: - return gettext.pgettext("uvindex", "Very High") + return C_("uvindex", "Very High") else: - return gettext.pgettext("uvindex", "Extreme") + return C_("uvindex", "Extreme") def classify_humidity_level(uv_index): if uv_index < 50: - return gettext.pgettext("humidity", "Low") + return C_("humidity", "Low") elif uv_index <= 80: - return gettext.pgettext("humidity", "Moderate") + return C_("humidity", "Moderate") else: - return gettext.pgettext("humidity", "High") + return C_("humidity", "High") def classify_presssure_level(pressure): if pressure < 940: - return gpettext.pgettext("pressure", "Low") + return C_("pressure", "Low") elif pressure <= 1010: - return gettext.pgettext("pressure", "Normal") + return C_("pressure", "Normal") else: - return gettext.pgettext("pressure", "High") + return C_("pressure", "High") def classify_wind_speed_level(wind_speed): @@ -150,11 +150,11 @@ def classify_wind_speed_level(wind_speed): elif wind_speed <= 25: return _("Light") elif wind_speed <= 40: - return gettext.pgettext("wind", "Moderate") + return C_("wind", "Moderate") elif wind_speed <= 60: return _("Strong") else: - return gettext.pgettext("wind", "Extreme") + return C_("wind", "Extreme") def transform_visibility_data(unit, data): diff --git a/update-pot b/update-pot index 675d6bd..1852598 100755 --- a/update-pot +++ b/update-pot @@ -1,2 +1,2 @@ #!/bin/bash -xgettext --keyword=_ --keyword=N_ --keyword=pgettext:1c,2 --output=po/mousam.pot -f po/POTFILES +xgettext --keyword=_ --keyword=N_ --keyword=C_:1c,2 --output=po/mousam.pot -f po/POTFILES