From bbb56df6b0bbf1763643b90cc811a8273085968a Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 2 Jul 2019 13:38:09 -0700 Subject: [PATCH] i18n: Move static/locale back to locale. As of commit cff40c557b2a35e03ac03af1125e19ba88555aef (#9300), these files are no longer served directly to the browser. Disentangle them from the static asset pipeline so we can refactor it without worrying about them. This has the side effect of eliminating the accidental duplication of translation data via hash-naming in our release tarballs. This reverts commit b546391f0b826824727d6d5f1fcf0a30a554328a (#1148). Signed-off-by: Anders Kaseorg --- .gitignore | 6 ++++++ .tx/config | 20 +++++++++---------- docs/overview/directory-structure.md | 4 +--- docs/subsystems/dependencies.md | 2 +- docs/subsystems/email.md | 2 +- docs/translating/internationalization.md | 4 ++-- .../bg/LC_MESSAGES/django.po | 0 .../locale => locale}/bg/translations.json | 0 .../ca/LC_MESSAGES/django.po | 0 .../locale => locale}/ca/translations.json | 0 .../cs/LC_MESSAGES/django.po | 0 .../locale => locale}/cs/translations.json | 0 .../de/LC_MESSAGES/django.po | 0 .../locale => locale}/de/translations.json | 0 .../en_GB/LC_MESSAGES/django.po | 0 .../locale => locale}/en_GB/translations.json | 0 .../es/LC_MESSAGES/django.po | 0 .../locale => locale}/es/translations.json | 0 .../fi/LC_MESSAGES/django.po | 0 .../locale => locale}/fi/translations.json | 0 .../fr/LC_MESSAGES/django.po | 0 .../locale => locale}/fr/translations.json | 0 .../gl/LC_MESSAGES/django.po | 0 .../locale => locale}/gl/translations.json | 0 .../hi/LC_MESSAGES/django.po | 0 .../locale => locale}/hi/translations.json | 0 .../hu/LC_MESSAGES/django.po | 0 .../locale => locale}/hu/translations.json | 0 .../id_ID/LC_MESSAGES/django.po | 0 .../locale => locale}/id_ID/translations.json | 0 .../it/LC_MESSAGES/django.po | 0 .../locale => locale}/it/translations.json | 0 .../ja/LC_MESSAGES/django.po | 0 .../locale => locale}/ja/translations.json | 0 .../ko/LC_MESSAGES/django.po | 0 .../locale => locale}/ko/translations.json | 0 .../ml/LC_MESSAGES/django.po | 0 .../locale => locale}/ml/translations.json | 0 {static/locale => locale}/mobile_info.json | 0 .../nl/LC_MESSAGES/django.po | 0 .../locale => locale}/nl/translations.json | 0 .../pl/LC_MESSAGES/django.po | 0 .../locale => locale}/pl/translations.json | 0 .../pt/LC_MESSAGES/django.po | 0 .../locale => locale}/pt/translations.json | 0 .../ru/LC_MESSAGES/django.po | 0 .../locale => locale}/ru/translations.json | 0 .../sr/LC_MESSAGES/django.po | 0 .../locale => locale}/sr/translations.json | 0 .../ta/LC_MESSAGES/django.po | 0 .../locale => locale}/ta/translations.json | 0 .../tr/LC_MESSAGES/django.po | 0 .../locale => locale}/tr/translations.json | 0 .../uk/LC_MESSAGES/django.po | 0 .../locale => locale}/uk/translations.json | 0 .../zh_Hans/LC_MESSAGES/django.po | 0 .../zh_Hans/translations.json | 0 .../zh_Hant/LC_MESSAGES/django.po | 0 .../zh_Hant/translations.json | 0 scripts/lib/process-mobile-i18n | 8 ++++---- static/.gitignore | 6 ------ tools/build-release-tarball | 2 +- tools/check-capitalization | 4 ++-- tools/check-frontend-i18n | 2 +- tools/i18n/tagmessages | 2 +- tools/lib/provision.py | 4 ++-- tools/linter_lib/exclude.py | 2 +- tools/update-prod-static | 4 ---- zerver/lib/i18n.py | 4 ++-- zerver/management/commands/compilemessages.py | 19 ++++++------------ zerver/management/commands/makemessages.py | 2 +- zproject/settings.py | 2 +- 72 files changed, 43 insertions(+), 56 deletions(-) rename {static/locale => locale}/bg/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/bg/translations.json (100%) rename {static/locale => locale}/ca/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/ca/translations.json (100%) rename {static/locale => locale}/cs/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/cs/translations.json (100%) rename {static/locale => locale}/de/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/de/translations.json (100%) rename {static/locale => locale}/en_GB/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/en_GB/translations.json (100%) rename {static/locale => locale}/es/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/es/translations.json (100%) rename {static/locale => locale}/fi/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/fi/translations.json (100%) rename {static/locale => locale}/fr/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/fr/translations.json (100%) rename {static/locale => locale}/gl/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/gl/translations.json (100%) rename {static/locale => locale}/hi/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/hi/translations.json (100%) rename {static/locale => locale}/hu/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/hu/translations.json (100%) rename {static/locale => locale}/id_ID/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/id_ID/translations.json (100%) rename {static/locale => locale}/it/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/it/translations.json (100%) rename {static/locale => locale}/ja/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/ja/translations.json (100%) rename {static/locale => locale}/ko/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/ko/translations.json (100%) rename {static/locale => locale}/ml/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/ml/translations.json (100%) rename {static/locale => locale}/mobile_info.json (100%) rename {static/locale => locale}/nl/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/nl/translations.json (100%) rename {static/locale => locale}/pl/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/pl/translations.json (100%) rename {static/locale => locale}/pt/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/pt/translations.json (100%) rename {static/locale => locale}/ru/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/ru/translations.json (100%) rename {static/locale => locale}/sr/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/sr/translations.json (100%) rename {static/locale => locale}/ta/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/ta/translations.json (100%) rename {static/locale => locale}/tr/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/tr/translations.json (100%) rename {static/locale => locale}/uk/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/uk/translations.json (100%) rename {static/locale => locale}/zh_Hans/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/zh_Hans/translations.json (100%) rename {static/locale => locale}/zh_Hant/LC_MESSAGES/django.po (100%) rename {static/locale => locale}/zh_Hant/translations.json (100%) diff --git a/.gitignore b/.gitignore index 68f1d3e0f7..bfaf2eb613 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,12 @@ package-lock.json # Dockerfiles generated for CircleCI /tools/circleci/images +# Generated i18n data +/locale/en +/locale/language_options.json +/locale/language_name_map.json +/locale/*/mobile.json + # Static build *.mo npm-debug.log diff --git a/.tx/config b/.tx/config index 7854ad217e..c55c67fe30 100644 --- a/.tx/config +++ b/.tx/config @@ -3,32 +3,32 @@ host = https://www.transifex.com lang_map = zh-Hans: zh_Hans, zh-Hant: zh_Hant [zulip.djangopo] -file_filter = static/locale//LC_MESSAGES/django.po -source_file = static/locale/en/LC_MESSAGES/django.po +file_filter = locale//LC_MESSAGES/django.po +source_file = locale/en/LC_MESSAGES/django.po source_lang = en type = PO [zulip.translationsjson] -file_filter = static/locale//translations.json -source_file = static/locale/en/translations.json +file_filter = locale//translations.json +source_file = locale/en/translations.json source_lang = en type = KEYVALUEJSON [zulip.mobile] -file_filter = static/locale//mobile.json -source_file = static/locale/en/mobile.json +file_filter = locale//mobile.json +source_file = locale/en/mobile.json source_lang = en type = KEYVALUEJSON [zulip-test.djangopo] -file_filter = static/locale//LC_MESSAGES/django.po -source_file = static/locale/en/LC_MESSAGES/django.po +file_filter = locale//LC_MESSAGES/django.po +source_file = locale/en/LC_MESSAGES/django.po source_lang = en type = PO [zulip-test.translationsjson] -file_filter = static/locale//translations.json -source_file = static/locale/en/translations.json +file_filter = locale//translations.json +source_file = locale/en/translations.json source_lang = en type = KEYVALUEJSON diff --git a/docs/overview/directory-structure.md b/docs/overview/directory-structure.md index feaf4b8ffe..58780551c8 100644 --- a/docs/overview/directory-structure.md +++ b/docs/overview/directory-structure.md @@ -169,9 +169,7 @@ This is used to deploy essentially all configuration in production. ### Translation files -* `locale/` Backend (Django) translations data files. - -* `static/locale/` Frontend translations data files. +* `locale/` Backend (Django) and frontend translation data files. ----------------------------------------------------------------------- diff --git a/docs/subsystems/dependencies.md b/docs/subsystems/dependencies.md index 298905f980..487215d6a4 100644 --- a/docs/subsystems/dependencies.md +++ b/docs/subsystems/dependencies.md @@ -318,7 +318,7 @@ several files from the source data, which we manage similar to our emoji, but without the caching (and thus without the garbage-collection). New translations data is downloaded from Transifex and then compiled to generate both the production locale -files and also language data in `static/locale/language*.json` using +files and also language data in `locale/language*.json` using `manage.py compilemessages`, which extends the default Django implementation of that tool. diff --git a/docs/subsystems/email.md b/docs/subsystems/email.md index 88e3bb1e8f..852c0fe13c 100644 --- a/docs/subsystems/email.md +++ b/docs/subsystems/email.md @@ -133,7 +133,7 @@ in our emails. One can test whether you did the translating part right by running `tools/inline-email-css && manage.py makemessages` and then searching -for the strings in `static/locale/en/LC_MESSAGES/django.po`; if there +for the strings in `locale/en/LC_MESSAGES/django.po`; if there are multiple copies or they contain CSS colors, you did it wrong. A final note for translating emails is that strings that are sent to diff --git a/docs/translating/internationalization.md b/docs/translating/internationalization.md index d0cce09070..9c7b4ac026 100644 --- a/docs/translating/internationalization.md +++ b/docs/translating/internationalization.md @@ -110,9 +110,9 @@ sense of how everything fits together. All the translation magic happens through resource files which hold the translated text. Backend resource files are located at -`static/locale//LC_MESSAGES/django.po`, while frontend +`locale//LC_MESSAGES/django.po`, while frontend resource files are located at -`static/locale//translations.json` (and mobile at +`locale//translations.json` (and mobile at `mobile.json`). These files are uploaded to [Transifex][], where they can be translated. diff --git a/static/locale/bg/LC_MESSAGES/django.po b/locale/bg/LC_MESSAGES/django.po similarity index 100% rename from static/locale/bg/LC_MESSAGES/django.po rename to locale/bg/LC_MESSAGES/django.po diff --git a/static/locale/bg/translations.json b/locale/bg/translations.json similarity index 100% rename from static/locale/bg/translations.json rename to locale/bg/translations.json diff --git a/static/locale/ca/LC_MESSAGES/django.po b/locale/ca/LC_MESSAGES/django.po similarity index 100% rename from static/locale/ca/LC_MESSAGES/django.po rename to locale/ca/LC_MESSAGES/django.po diff --git a/static/locale/ca/translations.json b/locale/ca/translations.json similarity index 100% rename from static/locale/ca/translations.json rename to locale/ca/translations.json diff --git a/static/locale/cs/LC_MESSAGES/django.po b/locale/cs/LC_MESSAGES/django.po similarity index 100% rename from static/locale/cs/LC_MESSAGES/django.po rename to locale/cs/LC_MESSAGES/django.po diff --git a/static/locale/cs/translations.json b/locale/cs/translations.json similarity index 100% rename from static/locale/cs/translations.json rename to locale/cs/translations.json diff --git a/static/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po similarity index 100% rename from static/locale/de/LC_MESSAGES/django.po rename to locale/de/LC_MESSAGES/django.po diff --git a/static/locale/de/translations.json b/locale/de/translations.json similarity index 100% rename from static/locale/de/translations.json rename to locale/de/translations.json diff --git a/static/locale/en_GB/LC_MESSAGES/django.po b/locale/en_GB/LC_MESSAGES/django.po similarity index 100% rename from static/locale/en_GB/LC_MESSAGES/django.po rename to locale/en_GB/LC_MESSAGES/django.po diff --git a/static/locale/en_GB/translations.json b/locale/en_GB/translations.json similarity index 100% rename from static/locale/en_GB/translations.json rename to locale/en_GB/translations.json diff --git a/static/locale/es/LC_MESSAGES/django.po b/locale/es/LC_MESSAGES/django.po similarity index 100% rename from static/locale/es/LC_MESSAGES/django.po rename to locale/es/LC_MESSAGES/django.po diff --git a/static/locale/es/translations.json b/locale/es/translations.json similarity index 100% rename from static/locale/es/translations.json rename to locale/es/translations.json diff --git a/static/locale/fi/LC_MESSAGES/django.po b/locale/fi/LC_MESSAGES/django.po similarity index 100% rename from static/locale/fi/LC_MESSAGES/django.po rename to locale/fi/LC_MESSAGES/django.po diff --git a/static/locale/fi/translations.json b/locale/fi/translations.json similarity index 100% rename from static/locale/fi/translations.json rename to locale/fi/translations.json diff --git a/static/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po similarity index 100% rename from static/locale/fr/LC_MESSAGES/django.po rename to locale/fr/LC_MESSAGES/django.po diff --git a/static/locale/fr/translations.json b/locale/fr/translations.json similarity index 100% rename from static/locale/fr/translations.json rename to locale/fr/translations.json diff --git a/static/locale/gl/LC_MESSAGES/django.po b/locale/gl/LC_MESSAGES/django.po similarity index 100% rename from static/locale/gl/LC_MESSAGES/django.po rename to locale/gl/LC_MESSAGES/django.po diff --git a/static/locale/gl/translations.json b/locale/gl/translations.json similarity index 100% rename from static/locale/gl/translations.json rename to locale/gl/translations.json diff --git a/static/locale/hi/LC_MESSAGES/django.po b/locale/hi/LC_MESSAGES/django.po similarity index 100% rename from static/locale/hi/LC_MESSAGES/django.po rename to locale/hi/LC_MESSAGES/django.po diff --git a/static/locale/hi/translations.json b/locale/hi/translations.json similarity index 100% rename from static/locale/hi/translations.json rename to locale/hi/translations.json diff --git a/static/locale/hu/LC_MESSAGES/django.po b/locale/hu/LC_MESSAGES/django.po similarity index 100% rename from static/locale/hu/LC_MESSAGES/django.po rename to locale/hu/LC_MESSAGES/django.po diff --git a/static/locale/hu/translations.json b/locale/hu/translations.json similarity index 100% rename from static/locale/hu/translations.json rename to locale/hu/translations.json diff --git a/static/locale/id_ID/LC_MESSAGES/django.po b/locale/id_ID/LC_MESSAGES/django.po similarity index 100% rename from static/locale/id_ID/LC_MESSAGES/django.po rename to locale/id_ID/LC_MESSAGES/django.po diff --git a/static/locale/id_ID/translations.json b/locale/id_ID/translations.json similarity index 100% rename from static/locale/id_ID/translations.json rename to locale/id_ID/translations.json diff --git a/static/locale/it/LC_MESSAGES/django.po b/locale/it/LC_MESSAGES/django.po similarity index 100% rename from static/locale/it/LC_MESSAGES/django.po rename to locale/it/LC_MESSAGES/django.po diff --git a/static/locale/it/translations.json b/locale/it/translations.json similarity index 100% rename from static/locale/it/translations.json rename to locale/it/translations.json diff --git a/static/locale/ja/LC_MESSAGES/django.po b/locale/ja/LC_MESSAGES/django.po similarity index 100% rename from static/locale/ja/LC_MESSAGES/django.po rename to locale/ja/LC_MESSAGES/django.po diff --git a/static/locale/ja/translations.json b/locale/ja/translations.json similarity index 100% rename from static/locale/ja/translations.json rename to locale/ja/translations.json diff --git a/static/locale/ko/LC_MESSAGES/django.po b/locale/ko/LC_MESSAGES/django.po similarity index 100% rename from static/locale/ko/LC_MESSAGES/django.po rename to locale/ko/LC_MESSAGES/django.po diff --git a/static/locale/ko/translations.json b/locale/ko/translations.json similarity index 100% rename from static/locale/ko/translations.json rename to locale/ko/translations.json diff --git a/static/locale/ml/LC_MESSAGES/django.po b/locale/ml/LC_MESSAGES/django.po similarity index 100% rename from static/locale/ml/LC_MESSAGES/django.po rename to locale/ml/LC_MESSAGES/django.po diff --git a/static/locale/ml/translations.json b/locale/ml/translations.json similarity index 100% rename from static/locale/ml/translations.json rename to locale/ml/translations.json diff --git a/static/locale/mobile_info.json b/locale/mobile_info.json similarity index 100% rename from static/locale/mobile_info.json rename to locale/mobile_info.json diff --git a/static/locale/nl/LC_MESSAGES/django.po b/locale/nl/LC_MESSAGES/django.po similarity index 100% rename from static/locale/nl/LC_MESSAGES/django.po rename to locale/nl/LC_MESSAGES/django.po diff --git a/static/locale/nl/translations.json b/locale/nl/translations.json similarity index 100% rename from static/locale/nl/translations.json rename to locale/nl/translations.json diff --git a/static/locale/pl/LC_MESSAGES/django.po b/locale/pl/LC_MESSAGES/django.po similarity index 100% rename from static/locale/pl/LC_MESSAGES/django.po rename to locale/pl/LC_MESSAGES/django.po diff --git a/static/locale/pl/translations.json b/locale/pl/translations.json similarity index 100% rename from static/locale/pl/translations.json rename to locale/pl/translations.json diff --git a/static/locale/pt/LC_MESSAGES/django.po b/locale/pt/LC_MESSAGES/django.po similarity index 100% rename from static/locale/pt/LC_MESSAGES/django.po rename to locale/pt/LC_MESSAGES/django.po diff --git a/static/locale/pt/translations.json b/locale/pt/translations.json similarity index 100% rename from static/locale/pt/translations.json rename to locale/pt/translations.json diff --git a/static/locale/ru/LC_MESSAGES/django.po b/locale/ru/LC_MESSAGES/django.po similarity index 100% rename from static/locale/ru/LC_MESSAGES/django.po rename to locale/ru/LC_MESSAGES/django.po diff --git a/static/locale/ru/translations.json b/locale/ru/translations.json similarity index 100% rename from static/locale/ru/translations.json rename to locale/ru/translations.json diff --git a/static/locale/sr/LC_MESSAGES/django.po b/locale/sr/LC_MESSAGES/django.po similarity index 100% rename from static/locale/sr/LC_MESSAGES/django.po rename to locale/sr/LC_MESSAGES/django.po diff --git a/static/locale/sr/translations.json b/locale/sr/translations.json similarity index 100% rename from static/locale/sr/translations.json rename to locale/sr/translations.json diff --git a/static/locale/ta/LC_MESSAGES/django.po b/locale/ta/LC_MESSAGES/django.po similarity index 100% rename from static/locale/ta/LC_MESSAGES/django.po rename to locale/ta/LC_MESSAGES/django.po diff --git a/static/locale/ta/translations.json b/locale/ta/translations.json similarity index 100% rename from static/locale/ta/translations.json rename to locale/ta/translations.json diff --git a/static/locale/tr/LC_MESSAGES/django.po b/locale/tr/LC_MESSAGES/django.po similarity index 100% rename from static/locale/tr/LC_MESSAGES/django.po rename to locale/tr/LC_MESSAGES/django.po diff --git a/static/locale/tr/translations.json b/locale/tr/translations.json similarity index 100% rename from static/locale/tr/translations.json rename to locale/tr/translations.json diff --git a/static/locale/uk/LC_MESSAGES/django.po b/locale/uk/LC_MESSAGES/django.po similarity index 100% rename from static/locale/uk/LC_MESSAGES/django.po rename to locale/uk/LC_MESSAGES/django.po diff --git a/static/locale/uk/translations.json b/locale/uk/translations.json similarity index 100% rename from static/locale/uk/translations.json rename to locale/uk/translations.json diff --git a/static/locale/zh_Hans/LC_MESSAGES/django.po b/locale/zh_Hans/LC_MESSAGES/django.po similarity index 100% rename from static/locale/zh_Hans/LC_MESSAGES/django.po rename to locale/zh_Hans/LC_MESSAGES/django.po diff --git a/static/locale/zh_Hans/translations.json b/locale/zh_Hans/translations.json similarity index 100% rename from static/locale/zh_Hans/translations.json rename to locale/zh_Hans/translations.json diff --git a/static/locale/zh_Hant/LC_MESSAGES/django.po b/locale/zh_Hant/LC_MESSAGES/django.po similarity index 100% rename from static/locale/zh_Hant/LC_MESSAGES/django.po rename to locale/zh_Hant/LC_MESSAGES/django.po diff --git a/static/locale/zh_Hant/translations.json b/locale/zh_Hant/translations.json similarity index 100% rename from static/locale/zh_Hant/translations.json rename to locale/zh_Hant/translations.json diff --git a/scripts/lib/process-mobile-i18n b/scripts/lib/process-mobile-i18n index 8d6a5885b9..f9cc902c02 100755 --- a/scripts/lib/process-mobile-i18n +++ b/scripts/lib/process-mobile-i18n @@ -6,12 +6,12 @@ from subprocess import check_output from typing import Dict, List def get_json_filename(locale: str) -> str: - return "static/locale/{}/mobile.json".format(locale) + return "locale/{}/mobile.json".format(locale) def get_locales() -> List[str]: - tracked_files = check_output(['git', 'ls-files', 'static/locale']) + tracked_files = check_output(['git', 'ls-files', 'locale']) tracked_files = tracked_files.decode().split() - regex = re.compile(r'static/locale/(\w+)/LC_MESSAGES/django.po') + regex = re.compile(r'locale/(\w+)/LC_MESSAGES/django.po') locales = ['en'] for tracked_file in tracked_files: matched = regex.search(tracked_file) @@ -37,7 +37,7 @@ for locale in get_locales(): translation_stats.update({locale: stats}) locale_paths.append(path) -stats_path = os.path.join('static', 'locale', 'mobile_info.json') +stats_path = os.path.join('locale', 'mobile_info.json') with open(stats_path, 'w') as f: json.dump(translation_stats, f, indent=2, sort_keys=True) f.write('\n') diff --git a/static/.gitignore b/static/.gitignore index aae34a3f10..428366b85b 100644 --- a/static/.gitignore +++ b/static/.gitignore @@ -16,11 +16,5 @@ # From tools/setup/generate-custom-icon-webfont /generated/icons/ -# Generated i18n data -/locale/en -/locale/language_options.json -/locale/language_name_map.json -/locale/*/mobile.json - # Legacy emoji data directory /third/emoji-data diff --git a/tools/build-release-tarball b/tools/build-release-tarball index d128d4b725..9f0340b0db 100755 --- a/tools/build-release-tarball +++ b/tools/build-release-tarball @@ -114,7 +114,7 @@ echo "$version" > version cd "$TMPDIR" -tar --append -f "$TARBALL" "$prefix/prod-static" "$prefix/build_id" "$prefix/version" "$prefix/zulip-git-version" "$prefix/staticfiles.json" "$prefix/templates/zerver/emails/compiled" "$prefix/webpack-stats-production.json" +tar --append -f "$TARBALL" "$prefix/prod-static" "$prefix/build_id" "$prefix/version" "$prefix/zulip-git-version" "$prefix/locale" "$prefix/staticfiles.json" "$prefix/templates/zerver/emails/compiled" "$prefix/webpack-stats-production.json" rm -rf "$prefix" diff --git a/tools/check-capitalization b/tools/check-capitalization index 84486c307f..c99f08ceab 100755 --- a/tools/check-capitalization +++ b/tools/check-capitalization @@ -33,12 +33,12 @@ if __name__ == '__main__': subprocess.call(['./manage.py', 'makemessages', '--locale', 'en'], stderr=subprocess.STDOUT) - with open('static/locale/en/translations.json') as f: + with open('locale/en/translations.json') as f: data = json.load(f) frontend = check_capitalization(list(data.keys())) frontend_errors, frontend_ignored, banned_errors_front = frontend - with open('static/locale/en/LC_MESSAGES/django.po') as f: + with open('locale/en/LC_MESSAGES/django.po') as f: rows = [r for r in DJANGO_PO_REGEX.findall(f.read()) if r] backend = check_capitalization(rows) backend_errors, backend_ignored, banned_errors_back = backend diff --git a/tools/check-frontend-i18n b/tools/check-frontend-i18n index a980b74e2c..3201cc2581 100755 --- a/tools/check-frontend-i18n +++ b/tools/check-frontend-i18n @@ -33,7 +33,7 @@ if __name__ == '__main__': subprocess.call(['./manage.py', 'makemessages', '--locale', 'en'], stderr=subprocess.STDOUT) - with open('static/locale/en/translations.json') as f: + with open('locale/en/translations.json') as f: data = json.load(f) found = find_handlebars(list(data.keys())) diff --git a/tools/i18n/tagmessages b/tools/i18n/tagmessages index 20f7a0b0d8..98265b4263 100755 --- a/tools/i18n/tagmessages +++ b/tools/i18n/tagmessages @@ -19,7 +19,7 @@ project_slug = 'zulip-test' # HACK hardcode tools_dir = os.path.dirname(os.path.abspath(__file__)) root_dir = os.path.dirname(tools_dir) # Choose any translation file for processing all strings. -po = polib.pofile(os.path.join(root_dir, 'static', 'locale', 'de', 'LC_MESSAGES', 'django.po')) +po = polib.pofile(os.path.join(root_dir, 'locale', 'de', 'LC_MESSAGES', 'django.po')) for entry in po: tag = entry.comment if tag: diff --git a/tools/lib/provision.py b/tools/lib/provision.py index b0bcd571ec..f02e8b92b4 100755 --- a/tools/lib/provision.py +++ b/tools/lib/provision.py @@ -561,8 +561,8 @@ def main(options): # Consider updating generated translations data: both `.mo` # files and `language-options.json`. paths = ['zerver/management/commands/compilemessages.py'] - paths += glob.glob('static/locale/*/LC_MESSAGES/*.po') - paths += glob.glob('static/locale/*/translations.json') + paths += glob.glob('locale/*/LC_MESSAGES/*.po') + paths += glob.glob('locale/*/translations.json') if file_or_package_hash_updated(paths, "last_compilemessages_hash", options.is_force): run(["./manage.py", "compilemessages"]) diff --git a/tools/linter_lib/exclude.py b/tools/linter_lib/exclude.py index e83e93d1a9..709804ffeb 100644 --- a/tools/linter_lib/exclude.py +++ b/tools/linter_lib/exclude.py @@ -9,7 +9,7 @@ EXCLUDED_FILES = [ # Transifex syncs translation.json files without trailing # newlines; there's nothing other than trailing newlines we'd be # checking for in these anyway. - "static/locale", + "locale", ] PUPPET_CHECK_RULES_TO_EXCLUDE = [ diff --git a/tools/update-prod-static b/tools/update-prod-static index a9d986b406..3600bece7d 100755 --- a/tools/update-prod-static +++ b/tools/update-prod-static @@ -100,10 +100,6 @@ os.makedirs('prod-static', exist_ok=True) shutil.move(os.path.join(settings.STATIC_ROOT, 'source-map'), 'prod-static/source-map') -# Move language_options.json to the production release -run(['cp', '-aT', 'static/locale', os.path.join(settings.STATIC_ROOT, 'locale')], - stdout=fp, stderr=fp) - # Generate /team page markdown for authors authors_cmd = ['./tools/update-authors-json'] if os.environ.get("TRAVIS"): diff --git a/zerver/lib/i18n.py b/zerver/lib/i18n.py index 377b0150fc..4a48195fed 100644 --- a/zerver/lib/i18n.py +++ b/zerver/lib/i18n.py @@ -26,7 +26,7 @@ def with_language(string: str, language: str) -> str: @lru_cache() def get_language_list() -> List[Dict[str, Any]]: - path = os.path.join(settings.STATIC_ROOT, 'locale', 'language_name_map.json') + path = os.path.join(settings.DEPLOY_ROOT, 'locale', 'language_name_map.json') with open(path, 'r') as reader: languages = ujson.load(reader) return languages['name_map'] @@ -88,7 +88,7 @@ def get_language_translation_data(language: str) -> Dict[str, str]: language = 'zh_Hant' elif language == 'id-id': language = 'id_ID' - path = os.path.join(settings.STATIC_ROOT, 'locale', language, 'translations.json') + path = os.path.join(settings.DEPLOY_ROOT, 'locale', language, 'translations.json') try: with open(path, 'r') as reader: return ujson.load(reader) diff --git a/zerver/management/commands/compilemessages.py b/zerver/management/commands/compilemessages.py index ac8baa9839..17d702acf1 100644 --- a/zerver/management/commands/compilemessages.py +++ b/zerver/management/commands/compilemessages.py @@ -27,13 +27,6 @@ class Command(compilemessages.Command): help='Stop execution in case of errors.') def handle(self, *args: Any, **options: Any) -> None: - if settings.PRODUCTION: - # HACK: When using upgrade-zulip-from-git, we're in a - # production environment where STATIC_ROOT will include - # past versions; this ensures we only process the current - # version - settings.STATIC_ROOT = os.path.join(settings.DEPLOY_ROOT, "static") - settings.LOCALE_PATHS = (os.path.join(settings.DEPLOY_ROOT, 'static/locale'),) super().handle(*args, **options) self.strict = options['strict'] self.extract_language_options() @@ -41,9 +34,9 @@ class Command(compilemessages.Command): def create_language_name_map(self) -> None: join = os.path.join - static_root = settings.STATIC_ROOT - path = join(static_root, 'locale', 'language_options.json') - output_path = join(static_root, 'locale', 'language_name_map.json') + deploy_root = settings.DEPLOY_ROOT + path = join(deploy_root, 'locale', 'language_options.json') + output_path = join(deploy_root, 'locale', 'language_name_map.json') with open(path, 'r') as reader: languages = ujson.load(reader) @@ -80,9 +73,9 @@ class Command(compilemessages.Command): raise Exception("Unknown language %s" % (locale,)) def get_locales(self) -> List[str]: - tracked_files = check_output(['git', 'ls-files', 'static/locale']) + tracked_files = check_output(['git', 'ls-files', 'locale']) tracked_files = tracked_files.decode().split() - regex = re.compile(r'static/locale/(\w+)/LC_MESSAGES/django.po') + regex = re.compile(r'locale/(\w+)/LC_MESSAGES/django.po') locales = ['en'] for tracked_file in tracked_files: matched = regex.search(tracked_file) @@ -92,7 +85,7 @@ class Command(compilemessages.Command): return locales def extract_language_options(self) -> None: - locale_path = "{}/locale".format(settings.STATIC_ROOT) + locale_path = "{}/locale".format(settings.DEPLOY_ROOT) output_path = "{}/language_options.json".format(locale_path) data = {'languages': []} # type: Dict[str, List[Dict[str, Any]]] diff --git a/zerver/management/commands/makemessages.py b/zerver/management/commands/makemessages.py index 7fc9fd068a..86bf531a9f 100644 --- a/zerver/management/commands/makemessages.py +++ b/zerver/management/commands/makemessages.py @@ -78,7 +78,7 @@ class Command(makemessages.Command): default='static/templates', help='Name of the Handlebars template directory') parser.add_argument('--frontend-output', type=str, - default='static/locale', + default='locale', help='Name of the frontend messages output directory') parser.add_argument('--frontend-namespace', type=str, default='translations.json', diff --git a/zproject/settings.py b/zproject/settings.py index efe30bed09..5f4334ef55 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -889,7 +889,7 @@ else: # If changing this, you need to also the hack modifications to this in # our compilemessages management command. -LOCALE_PATHS = (os.path.join(STATIC_ROOT, 'locale'),) +LOCALE_PATHS = (os.path.join(DEPLOY_ROOT, 'locale'),) # We want all temporary uploaded files to be stored on disk. FILE_UPLOAD_MAX_MEMORY_SIZE = 0