| Index: grit/format/chrome_messages_json.py
|
| diff --git a/grit/format/chrome_messages_json.py b/grit/format/chrome_messages_json.py
|
| index 560912288b1562e483c07cfbf1bd35e2af1f30c5..7b370d7fdca26ed966b45ad0a42c709715b8885b 100644
|
| --- a/grit/format/chrome_messages_json.py
|
| +++ b/grit/format/chrome_messages_json.py
|
| @@ -6,6 +6,7 @@
|
| """Formats as a .json file that can be used to localize Google Chrome
|
| extensions."""
|
|
|
| +from json import JSONEncoder
|
| import re
|
| import types
|
|
|
| @@ -16,20 +17,19 @@ def Format(root, lang='en', output_dir='.'):
|
| """Format the messages as JSON."""
|
| yield '{\n'
|
|
|
| + encoder = JSONEncoder();
|
| format = (' "%s": {\n'
|
| - ' "message": "%s"\n'
|
| + ' "message": %s\n'
|
| ' }')
|
| first = True
|
| for child in root.ActiveDescendants():
|
| if isinstance(child, message.MessageNode):
|
| - loc_message = child.Translate(lang)
|
| - loc_message = re.sub(r'\\', r'\\\\', loc_message)
|
| - loc_message = re.sub(r'"', r'\"', loc_message)
|
| -
|
| id = child.attrs['name']
|
| if id.startswith('IDR_'):
|
| id = id[4:]
|
|
|
| + loc_message = encoder.encode(child.Translate(lang))
|
| +
|
| if not first:
|
| yield ',\n'
|
| first = False
|
|
|