Commit 364c6973 authored by Mike Frysinger's avatar Mike Frysinger Committed by Commit Bot

grit: format output using UTF-8

Since Chrome is the only thing that loads these files, there's no need
to force them to use JSON escapes for non-ASCII Unicode codepoints.
Just use native UTF-8 encoding everywhere (especially since all the
files already have Unicode BOM's in them!).

It shouldn't make the readability of the files worse.  If anything, it
should improve it greatly, especially relative to the source grd files
(which use UTF-8), and for native readers.  Example delta for Arabic:
	CHROMEVOX_COLUMN_GRANULARITY
-		"\u0639\u0645\u0648\u062f"
+		"عمود"

On a Pixelbook, converting all the messages.json files in this way
shaves off ~1.4MiB.

Bug: 852585
Change-Id: I1978141717bbd69aec5a72c9d6769c6998419c1b
Reviewed-on: https://chromium-review.googlesource.com/1099881Reviewed-by: default avataragrieve <agrieve@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567085}
parent 906f7da4
......@@ -17,7 +17,7 @@ def Format(root, lang='en', output_dir='.'):
"""Format the messages as JSON."""
yield '{\n'
encoder = JSONEncoder();
encoder = JSONEncoder(ensure_ascii=False)
format = (' "%s": {\n'
' "message": %s%s\n'
' }')
......
......@@ -63,7 +63,7 @@ class ChromeMessagesJsonFormatUnittest(unittest.TestCase):
"message": "Simple message."
},
"QUOTES": {
"message": "element\\u2019s \\u201c%s\\u201d attribute"
"message": "element\u2019s \u201c%s\u201d attribute"
},
"PLACEHOLDERS": {
"message": "%1$d error, %2$d warning"
......@@ -114,10 +114,10 @@ class ChromeMessagesJsonFormatUnittest(unittest.TestCase):
test = u"""
{
"ID_HELLO": {
"message": "H\\u00e9P\\u00e9ll\\u00f4P\\u00f4!"
"message": "H\u00e9P\u00e9ll\u00f4P\u00f4!"
},
"ID_HELLO_USER": {
"message": "H\\u00e9P\\u00e9ll\\u00f4P\\u00f4 %s"
"message": "H\u00e9P\u00e9ll\u00f4P\u00f4 %s"
}
}
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment