[geany/www.geany.org] a359e7: Add fallback language name for unknown locales by Babel
Enrico Tröger
git-noreply at xxxxx
Mon Aug 17 21:12:15 UTC 2020
Branch: refs/heads/master
Author: Enrico Tröger <enrico.troeger at uvena.de>
Committer: Enrico Tröger <enrico.troeger at uvena.de>
Date: Mon, 17 Aug 2020 21:12:15 UTC
Commit: a359e7efeeb91d73b7f25a93e884bd04ff69ba59
https://github.com/geany/www.geany.org/commit/a359e7efeeb91d73b7f25a93e884bd04ff69ba59
Log Message:
-----------
Add fallback language name for unknown locales by Babel
Babel uses Common Locale Data Repository (https://unicode.org/cldr/) and
its current version does not know the "ie" locale.
Modified Paths:
--------------
static_docs/generate_i18n_statistics.py
Modified: static_docs/generate_i18n_statistics.py
14 lines changed, 11 insertions(+), 3 deletions(-)
===================================================================
@@ -20,13 +20,18 @@
from time import time
import re
-from babel import Locale
+from babel import Locale, UnknownLocaleError
STATISTICS_REGEXP = re.compile(
r'(?P<translated>\d+) translated messages?(, (?P<fuzzy>\d+) fuzzy translations?)?(, (?P<untranslated>\d+) untranslated messages?)?') # noqa: E501 pylint: disable=line-too-long
LAST_TRANSLATOR_REGEXP = re.compile(r'^"Last-Translator: (?P<name>[\w -]+)\s*<?.+')
+# fallback language names for locales not (yet) supported by Babel
+KNOWN_LANGUAGE_NAMES = {
+ 'ie': 'Interlingue',
+}
+
class TranslationStatistics:
@@ -202,8 +207,11 @@ def _read_last_translator(self, filename):
# ----------------------------------------------------------------------
def _read_language_name(self, locale):
- locale = Locale.parse(locale)
- return locale.get_display_name(locale='en')
+ try:
+ locale = Locale.parse(locale)
+ return locale.get_display_name(locale='en')
+ except UnknownLocaleError:
+ return KNOWN_LANGUAGE_NAMES.get(locale)
# ----------------------------------------------------------------------
def _update_message_catalog(self):
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list