From 5c9287c2da3cae4316c6186eee21c79091bd5030 Mon Sep 17 00:00:00 2001 From: Yaron Budowski Date: Mon, 16 Sep 2024 12:57:45 +0200 Subject: [PATCH] #1360 / #1359 - fixes to invalid date formats + updated crowdin.py script to catch those errors --- crowdin.py | 15 +++++++++++++-- .../src/main/res/values-it-rIT/strings.xml | 2 +- iNaturalist/src/main/res/values-it/strings.xml | 2 +- .../src/main/res/values-pt-rBR/strings.xml | 2 +- .../src/main/res/values-sl-rSI/strings.xml | 2 +- iNaturalist/src/main/res/values-sl/strings.xml | 2 +- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/crowdin.py b/crowdin.py index 9af5d50d4..4e518fc90 100644 --- a/crowdin.py +++ b/crowdin.py @@ -34,7 +34,10 @@ class bcolors: "date_short_this_year", "date_short", "time_short_24_hour", - "time_short_12_hour" + "time_short_12_hour", + "date_obscured", + "date_long", + "date_long_with_time" ] # List of languages to skip date format check for - e.g. in Japanese, it's legal to have Japanese letters as part of the date format string: @@ -288,11 +291,19 @@ def validate_translation(locale, path, key, text, en_string, errors, warnings, print("\t\t{}".format(errors[path][key][-1])) if text and key in DATE_FORMAT_KEYS and locale not in SKIP_DATE_FORMAT_CHECK: + if "\\'\\'\\'" in text: + if key not in warnings[path]: + warnings[path][key] = [] + warnings[path][key].append( + f"Invalid date format characters: Has extra/unbalanced apostrophe") + if options.debug: + print("\t\t{}".format(warnings[path][key][-1])) + without_escaped_text = re.sub(r"'.+?'", "", text) potentially_formatted = re.sub(r"[^\w]", "", without_escaped_text) bad_characters = set( re.findall( - r"[^GyYMLwWDdFEuaHkKhmsSzZX]", + r"[^GyMLwWDdFEuaHkKhmsSzZX]", potentially_formatted) ) # Find bad chars in DATE_FORMAT_KEYS diff --git a/iNaturalist/src/main/res/values-it-rIT/strings.xml b/iNaturalist/src/main/res/values-it-rIT/strings.xml index 2fe53d6ee..6518e7866 100644 --- a/iNaturalist/src/main/res/values-it-rIT/strings.xml +++ b/iNaturalist/src/main/res/values-it-rIT/strings.xml @@ -959,7 +959,7 @@ le Linee Guida d MMM, yyyy - MMM \'\'\'yy + MMM \'\'yy MMMM d, yyyy hh:mma Mostra nomi comuni diff --git a/iNaturalist/src/main/res/values-it/strings.xml b/iNaturalist/src/main/res/values-it/strings.xml index 2fe53d6ee..6518e7866 100644 --- a/iNaturalist/src/main/res/values-it/strings.xml +++ b/iNaturalist/src/main/res/values-it/strings.xml @@ -959,7 +959,7 @@ le Linee Guida d MMM, yyyy - MMM \'\'\'yy + MMM \'\'yy MMMM d, yyyy hh:mma Mostra nomi comuni diff --git a/iNaturalist/src/main/res/values-pt-rBR/strings.xml b/iNaturalist/src/main/res/values-pt-rBR/strings.xml index 3c5ab94f5..d2b338975 100644 --- a/iNaturalist/src/main/res/values-pt-rBR/strings.xml +++ b/iNaturalist/src/main/res/values-pt-rBR/strings.xml @@ -957,7 +957,7 @@ d \'de\' MMM \'de\' yyyy - MMM \'\'YY + MMM \'\'yy d MMMM, yyyy hh:mmH Mostrar nomes comuns diff --git a/iNaturalist/src/main/res/values-sl-rSI/strings.xml b/iNaturalist/src/main/res/values-sl-rSI/strings.xml index 9d6a650ec..ba6c3b127 100644 --- a/iNaturalist/src/main/res/values-sl-rSI/strings.xml +++ b/iNaturalist/src/main/res/values-sl-rSI/strings.xml @@ -967,7 +967,7 @@ hh.mm - dd. MM. YYYY + dd. MM. yyyy dd. MMMM LLLL, hh.mma diff --git a/iNaturalist/src/main/res/values-sl/strings.xml b/iNaturalist/src/main/res/values-sl/strings.xml index 9d6a650ec..ba6c3b127 100644 --- a/iNaturalist/src/main/res/values-sl/strings.xml +++ b/iNaturalist/src/main/res/values-sl/strings.xml @@ -967,7 +967,7 @@ hh.mm - dd. MM. YYYY + dd. MM. yyyy dd. MMMM LLLL, hh.mma