Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: grit/format/chrome_messages_json_unittest.py

Issue 11152002: Add support for messages.json format used to localize Chrome extensions. (Closed) Base URL: http://git.chromium.org/external/grit-i18n.git@master
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « grit/format/chrome_messages_json.py ('k') | grit/format/js_map_format.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/format/chrome_messages_json_unittest.py
diff --git a/grit/format/js_map_format_unittest.py b/grit/format/chrome_messages_json_unittest.py
similarity index 71%
copy from grit/format/js_map_format_unittest.py
copy to grit/format/chrome_messages_json_unittest.py
index 28c70bda83f732b02f39351efed6f8cf84e37e34..1fc86b1cf9c0703943487d7992703acde003de41 100644
--- a/grit/format/js_map_format_unittest.py
+++ b/grit/format/chrome_messages_json_unittest.py
@@ -3,7 +3,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""Unittest for js_map_format.py.
+"""Unittest for chrome_messages_json.py.
"""
import os
@@ -18,8 +18,7 @@ from grit import grd_reader
from grit import util
from grit.tool import build
-
-class JsMapFormatUnittest(unittest.TestCase):
+class ChromeMessagesJsonFormatUnittest(unittest.TestCase):
def testMessages(self):
grd_text = u"""
@@ -39,6 +38,9 @@ class JsMapFormatUnittest(unittest.TestCase):
<message name="IDS_DOUBLE_QUOTES">
A "double quoted" message.
</message>
+ <message name="IDS_BACKSLASH">
+ \\
+ </message>
</messages>
"""
root = grd_reader.Parse(StringIO.StringIO(grd_text.encode('utf-8')),
@@ -46,14 +48,29 @@ class JsMapFormatUnittest(unittest.TestCase):
util.FixRootForUnittest(root)
buf = StringIO.StringIO()
- build.RcBuilder.ProcessNode(root, DummyOutput('js_map_format', 'en'), buf)
+ build.RcBuilder.ProcessNode(root, DummyOutput('chrome_messages_json', 'en'), buf)
output = buf.getvalue()
test = u"""
-localizedStrings["Simple message."] = "Simple message.";
-localizedStrings["element\u2019s \u201c%s\u201d attribute"] = "element\u2019s \u201c%s\u201d attribute";
-localizedStrings["%d error, %d warning"] = "%1$d error, %2$d warning";
-localizedStrings[" (%d)"] = " (%d)";
-localizedStrings["A \\\"double quoted\\\" message."] = "A \\\"double quoted\\\" message.";
+{
+ "IDS_SIMPLE_MESSAGE": {
+ "message": "Simple message."
+ },
+ "IDS_QUOTES": {
+ "message": "element\u2019s \u201c%s\u201d attribute"
+ },
+ "IDS_PLACEHOLDERS": {
+ "message": "%1$d error, %2$d warning"
+ },
+ "IDS_STARTS_WITH_SPACE": {
+ "message": "(%d)"
+ },
+ "IDS_DOUBLE_QUOTES": {
+ "message": "A \\"double quoted\\" message."
+ },
+ "IDS_BACKSLASH": {
+ "message": "\\\\"
+ }
+}
"""
self.failUnless(output.strip() == test.strip())
@@ -68,11 +85,17 @@ localizedStrings["A \\\"double quoted\\\" message."] = "A \\\"double quoted\\\"
util.FixRootForUnittest(root)
buf = StringIO.StringIO()
- build.RcBuilder.ProcessNode(root, DummyOutput('js_map_format', 'fr'), buf)
+ build.RcBuilder.ProcessNode(root, DummyOutput('chrome_messages_json', 'fr'), buf)
output = buf.getvalue()
test = u"""
-localizedStrings["Hello!"] = "H\xe9P\xe9ll\xf4P\xf4!";
-localizedStrings["Hello %s"] = "H\xe9P\xe9ll\xf4P\xf4 %s";
+{
+ "ID_HELLO": {
+ "message": "H\xe9P\xe9ll\xf4P\xf4!"
+ },
+ "ID_HELLO_USER": {
+ "message": "H\xe9P\xe9ll\xf4P\xf4 %s"
+ }
+}
"""
self.failUnless(output.strip() == test.strip())
@@ -92,5 +115,6 @@ class DummyOutput(object):
def GetOutputFilename(self):
return 'hello.gif'
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « grit/format/chrome_messages_json.py ('k') | grit/format/js_map_format.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698