Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

unescape-contents: Remove.

Anders Kaseorgb470df98da64
diff --git a/tools/i18n/sync-translations b/tools/i18n/sync-translations
index ab764b21ade..3dbbe2a6ecb 100755
--- a/tools/i18n/sync-translations
+++ b/tools/i18n/sync-translations
@@ -8,11 +8,6 @@ set -x
./manage.py makemessages --all
tx pull -a -f --mode=translator --minimum-perc=5 "$@"
-# For readability, we prefer UTF-8, not ascii, in these JSON files.
-find ./locale \
- -regextype sed \
- -regex '^\./locale/.*/\(mobile\|translations\).json$' \
- -exec ./tools/i18n/unescape-contents {} \;
# Normalize to Unicode Normalization Form C.
files="$(find locale -type f -name '*.json' -o -name '*.po')"
diff --git a/tools/i18n/unescape-contents b/tools/i18n/unescape-contents
deleted file mode 100755
index d080086c90f..00000000000
--- a/tools/i18n/unescape-contents
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/env python3
-
-import argparse
-import html
-import sys
-from typing import NamedTuple
-
-import orjson
-
-
-class CLIArgs(NamedTuple):
- unescape_html: bool
- filename: str
- indent_level: int
-
-
-def parse_args() -> CLIArgs:
- parser = argparse.ArgumentParser(
- prog="unescape-contents",
- description="Unescape Unicode and, optionally, HTML entities in a JSON file. Input file must be a JSON dictionary. Output will always be unescaped UTF-8.",
- )
-
- parser.add_argument("filename", type=str)
- parser.add_argument(
- "--unescape-html",
- action="store_true",
- dest="unescape_html",
- help="If the key of a dictionary field does not contain HTML escapes, unescape any HTML escapes found in the value",
- )
- parser.add_argument("--indent-level", dest="indent_level", type=int, default=2, required=False)
- args = parser.parse_args()
-
- return CLIArgs(args.unescape_html, args.filename, args.indent_level)
-
-
-if __name__ == "__main__":
- args = parse_args()
- print(f"unescaping file {args.filename}", file=sys.stderr)
-
- json_data: dict[str, str] = {}
-
- with open(args.filename, "rb") as source:
- json_data = orjson.loads(source.read())
-
- if args.unescape_html:
- for key, value in json_data.items():
- if key == html.unescape(key):
- json_data[key] = html.unescape(value)
- else:
- print(
- f'{args.filename}: key "{key}" contains HTML, not escaping HTML in value',
- file=sys.stderr,
- )
-
- with open(args.filename, mode="wb") as dest:
- # orjson ensures our output uses real UTF-8 codepoints for
- # human readability, rather than \u0000 style escape
- # sequences, providing us a somewhat-implicit JSON unescape.
- dest.write(
- orjson.dumps(
- json_data,
- option=orjson.OPT_APPEND_NEWLINE | orjson.OPT_INDENT_2 | orjson.OPT_SORT_KEYS,
- )
- )
diff --git a/tools/i18n/unescape-html-in-json-translations b/tools/i18n/unescape-html-in-json-translations
deleted file mode 100755
index 047cfcb79e6..00000000000
--- a/tools/i18n/unescape-html-in-json-translations
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env sh
-
-set -ex
-
-find ./locale \
- -regextype sed \
- -regex '^\./locale/.*/\(mobile\|translations\).json$' \
- -exec ./tools/i18n/unescape-contents --unescape-html {} \;