Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
i18n: Properly handle when a locale is removed from Weblate.
Alex Vandiver3ca5a49557ce
diff --git a/tools/i18n/sync-translations b/tools/i18n/sync-translationsindex f16924bec2c..419de4e882f 100755--- a/tools/i18n/sync-translations+++ b/tools/i18n/sync-translations@@ -26,6 +26,11 @@ if git rev-parse --verify --quiet "origin/$local_branch" >/dev/null; thenfigit checkout -b "$local_branch" "upstream/$branch"+# Clear out local `.mo` files which cause locale/*/LC_MESSAGES/+# directories to not be empty when their .po files vanish, so git+# doesn't remove the directory.+rm locale/*/LC_MESSAGES/*.mo+wlc lock "zulip/frontend$suffix"wlc lock "zulip/django$suffix"trap 'wlc unlock "zulip/frontend$suffix" && wlc unlock "zulip/django$suffix"' EXIT@@ -59,6 +64,10 @@ else# Update locale/*/legacy_stream_translations.json./tools/i18n/update-for-legacy-translations++ # Trim out any now-empty locale directories+ find locale/ -type d -empty -delete+git add locale/# Double-check that they all compilediff --git a/tools/i18n/update-for-legacy-translations b/tools/i18n/update-for-legacy-translationsindex 38cd19e2b0b..be406fff1fc 100755--- a/tools/i18n/update-for-legacy-translations+++ b/tools/i18n/update-for-legacy-translations@@ -1,4 +1,5 @@#!/usr/bin/env python3+import globimport osimport refrom subprocess import check_output@@ -239,11 +240,19 @@ def update_for_legacy_stream_translations(print(f"Updated {number_of_updates} strings in: {path}")+expected_legacy_filenames = set()for locale in get_locales():current = get_json_filename(locale)legacy = get_legacy_filename(locale)+ expected_legacy_filenames.add(legacy)if os.path.exists(current) and os.path.exists(legacy):print(f"Checking legacy translations for: {current}")current_translations = get_translations(current)legacy_translations = get_translations(legacy)update_for_legacy_stream_translations(current_translations, legacy_translations, current)++for extra_file in (+ set(glob.glob("locale/*/legacy_stream_translations.json")) - expected_legacy_filenames+):+ print(f"Removing dangling legacy translation file {extra_file}")+ os.unlink(extra_file)