Skip to content

Commit

Permalink
#1360 / #1359 - fixes to invalid date formats + updated crowdin.py sc…
Browse files Browse the repository at this point in the history
…ript to catch those errors
  • Loading branch information
budowski committed Sep 16, 2024
1 parent c555fc2 commit 5c9287c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
15 changes: 13 additions & 2 deletions crowdin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion iNaturalist/src/main/res/values-it-rIT/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ le <a href="https://www.inaturalist.org/pages/community+guidelines">Linee Guida
<!-- Long date formatting template. See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="date_long">d MMM, yyyy</string>
<!-- Obscured observations date formatting template (only month+year). See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="date_obscured">MMM \'\'\'yy</string>
<string name="date_obscured">MMM \'\'yy</string>
<!-- Long date with time formatting template. See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="date_long_with_time">MMMM d, yyyy hh:mma</string>
<string name="show_common_names">Mostra nomi comuni</string>
Expand Down
2 changes: 1 addition & 1 deletion iNaturalist/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ le <a href="https://www.inaturalist.org/pages/community+guidelines">Linee Guida
<!-- Long date formatting template. See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="date_long">d MMM, yyyy</string>
<!-- Obscured observations date formatting template (only month+year). See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="date_obscured">MMM \'\'\'yy</string>
<string name="date_obscured">MMM \'\'yy</string>
<!-- Long date with time formatting template. See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="date_long_with_time">MMMM d, yyyy hh:mma</string>
<string name="show_common_names">Mostra nomi comuni</string>
Expand Down
2 changes: 1 addition & 1 deletion iNaturalist/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@
<!-- Long date formatting template. See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="date_long">d \'de\' MMM \'de\' yyyy</string>
<!-- Obscured observations date formatting template (only month+year). See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="date_obscured">MMM \'\'YY</string>
<string name="date_obscured">MMM \'\'yy</string>
<!-- Long date with time formatting template. See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="date_long_with_time">d MMMM, yyyy hh:mmH</string>
<string name="show_common_names">Mostrar nomes comuns</string>
Expand Down
2 changes: 1 addition & 1 deletion iNaturalist/src/main/res/values-sl-rSI/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@
<!-- Short time formatting template for 12-hour locales. See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="time_short_12_hour">hh.mm</string>
<!-- Long date formatting template. See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="date_long">dd. MM. YYYY</string>
<string name="date_long">dd. MM. yyyy</string>
<!-- Obscured observations date formatting template (only month+year). See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<!-- Long date with time formatting template. See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="date_long_with_time">dd. MMMM LLLL, hh.mma</string>
Expand Down
2 changes: 1 addition & 1 deletion iNaturalist/src/main/res/values-sl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@
<!-- Short time formatting template for 12-hour locales. See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="time_short_12_hour">hh.mm</string>
<!-- Long date formatting template. See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="date_long">dd. MM. YYYY</string>
<string name="date_long">dd. MM. yyyy</string>
<!-- Obscured observations date formatting template (only month+year). See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<!-- Long date with time formatting template. See https://developer.android.com/reference/java/text/SimpleDateFormat#date-and-time-patterns for formatting options -->
<string name="date_long_with_time">dd. MMMM LLLL, hh.mma</string>
Expand Down

0 comments on commit 5c9287c

Please sign in to comment.