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

Side by Side Diff: grit/format/chrome_messages_json_unittest.py

Issue 1410023007: Skip missing translations when generating JSON resources. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: Created 5 years, 1 month 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
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 chrome_messages_json.py. 6 """Unittest for chrome_messages_json.py.
7 """ 7 """
8 8
9 import os 9 import os
10 import sys 10 import sys
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 "ID_HELLO": { 100 "ID_HELLO": {
101 "message": "H\\u00e9P\\u00e9ll\\u00f4P\\u00f4!" 101 "message": "H\\u00e9P\\u00e9ll\\u00f4P\\u00f4!"
102 }, 102 },
103 "ID_HELLO_USER": { 103 "ID_HELLO_USER": {
104 "message": "H\\u00e9P\\u00e9ll\\u00f4P\\u00f4 %s" 104 "message": "H\\u00e9P\\u00e9ll\\u00f4P\\u00f4 %s"
105 } 105 }
106 } 106 }
107 """ 107 """
108 self.assertEqual(test.strip(), output.strip()) 108 self.assertEqual(test.strip(), output.strip())
109 109
110 def testSkipMissingTranslations(self):
111 grd = """<?xml version="1.0" encoding="UTF-8"?>
112 <grit latest_public_release="2" current_release="3" source_lang_id="en" base_dir ="%s">
113 <outputs>
114 </outputs>
115 <release seq="3" allow_pseudo="False">
116 <messages>
117 <message name="ID_HELLO_NO_TRANSLATION">Hello not translated</message>
118 </messages>
119 </release>
120 </grit>"""
121 root = grd_reader.Parse(StringIO.StringIO(grd), dir=".")
122
123 buf = StringIO.StringIO()
124 build.RcBuilder.ProcessNode(root, DummyOutput('chrome_messages_json', 'fr'), buf)
125 output = buf.getvalue()
126 test = u"""
127 {
128
129 }
130 """
131 self.assertEqual(test.strip(), output.strip())
132
110 133
111 class DummyOutput(object): 134 class DummyOutput(object):
112 135
113 def __init__(self, type, language): 136 def __init__(self, type, language):
114 self.type = type 137 self.type = type
115 self.language = language 138 self.language = language
116 139
117 def GetType(self): 140 def GetType(self):
118 return self.type 141 return self.type
119 142
120 def GetLanguage(self): 143 def GetLanguage(self):
121 return self.language 144 return self.language
122 145
123 def GetOutputFilename(self): 146 def GetOutputFilename(self):
124 return 'hello.gif' 147 return 'hello.gif'
125 148
126 149
127 if __name__ == '__main__': 150 if __name__ == '__main__':
128 unittest.main() 151 unittest.main()
OLDNEW
« grit/format/chrome_messages_json.py ('K') | « grit/format/chrome_messages_json.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698