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

Side by Side Diff: grit/format/js_map_format_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 unified diff | Download patch
« no previous file with comments | « grit/format/js_map_format.py ('k') | grit/node/empty.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unittest for js_map_format.py. 6 """Unittest for js_map_format.py.
7 """ 7 """
8 8
9 import os 9 import os
10 import sys 10 import sys
(...skipping 21 matching lines...) Expand all
32 </message> 32 </message>
33 <message name="IDS_PLACEHOLDERS"> 33 <message name="IDS_PLACEHOLDERS">
34 <ph name="ERROR_COUNT">%1$d<ex>1</ex></ph> error, <ph name="WARNIN G_COUNT">%2$d<ex>1</ex></ph> warning 34 <ph name="ERROR_COUNT">%1$d<ex>1</ex></ph> error, <ph name="WARNIN G_COUNT">%2$d<ex>1</ex></ph> warning
35 </message> 35 </message>
36 <message name="IDS_STARTS_WITH_SPACE"> 36 <message name="IDS_STARTS_WITH_SPACE">
37 ''' (<ph name="COUNT">%d<ex>2</ex></ph>) 37 ''' (<ph name="COUNT">%d<ex>2</ex></ph>)
38 </message> 38 </message>
39 <message name="IDS_DOUBLE_QUOTES"> 39 <message name="IDS_DOUBLE_QUOTES">
40 A "double quoted" message. 40 A "double quoted" message.
41 </message> 41 </message>
42 <message name="IDS_BACKSLASH">
43 \\
44 </message>
42 </messages> 45 </messages>
43 """ 46 """
44 root = grd_reader.Parse(StringIO.StringIO(grd_text.encode('utf-8')), 47 root = grd_reader.Parse(StringIO.StringIO(grd_text.encode('utf-8')),
45 flexible_root=True) 48 flexible_root=True)
46 util.FixRootForUnittest(root) 49 util.FixRootForUnittest(root)
47 50
48 buf = StringIO.StringIO() 51 buf = StringIO.StringIO()
49 build.RcBuilder.ProcessNode(root, DummyOutput('js_map_format', 'en'), buf) 52 build.RcBuilder.ProcessNode(root, DummyOutput('js_map_format', 'en'), buf)
50 output = buf.getvalue() 53 output = buf.getvalue()
51 test = u""" 54 test = u"""
52 localizedStrings["Simple message."] = "Simple message."; 55 localizedStrings["Simple message."] = "Simple message.";
53 localizedStrings["element\u2019s \u201c%s\u201d attribute"] = "element\u2019s \u 201c%s\u201d attribute"; 56 localizedStrings["element\u2019s \u201c%s\u201d attribute"] = "element\u2019s \u 201c%s\u201d attribute";
54 localizedStrings["%d error, %d warning"] = "%1$d error, %2$d warning"; 57 localizedStrings["%d error, %d warning"] = "%1$d error, %2$d warning";
55 localizedStrings[" (%d)"] = " (%d)"; 58 localizedStrings[" (%d)"] = " (%d)";
56 localizedStrings["A \\\"double quoted\\\" message."] = "A \\\"double quoted\\\" message."; 59 localizedStrings["A \\\"double quoted\\\" message."] = "A \\\"double quoted\\\" message.";
60 localizedStrings["\\\\"] = "\\\\";
57 """ 61 """
58 self.failUnless(output.strip() == test.strip()) 62 self.failUnless(output.strip() == test.strip())
59 63
60 def testTranslations(self): 64 def testTranslations(self):
61 root = grd_reader.Parse(StringIO.StringIO(""" 65 root = grd_reader.Parse(StringIO.StringIO("""
62 <messages> 66 <messages>
63 <message name="ID_HELLO">Hello!</message> 67 <message name="ID_HELLO">Hello!</message>
64 <message name="ID_HELLO_USER">Hello <ph name="USERNAME">%s<ex> 68 <message name="ID_HELLO_USER">Hello <ph name="USERNAME">%s<ex>
65 Joi</ex></ph></message> 69 Joi</ex></ph></message>
66 </messages> 70 </messages>
(...skipping 20 matching lines...) Expand all
87 return self.type 91 return self.type
88 92
89 def GetLanguage(self): 93 def GetLanguage(self):
90 return self.language 94 return self.language
91 95
92 def GetOutputFilename(self): 96 def GetOutputFilename(self):
93 return 'hello.gif' 97 return 'hello.gif'
94 98
95 if __name__ == '__main__': 99 if __name__ == '__main__':
96 unittest.main() 100 unittest.main()
OLDNEW
« no previous file with comments | « grit/format/js_map_format.py ('k') | grit/node/empty.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698