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

Unified Diff: grit/format/data_pack.py

Issue 9965022: Allow substitution of messages as variables in other messages. (Closed) Base URL: https://grit-i18n.googlecode.com/svn/trunk
Patch Set: Fix unit tests for policy writers. Created 8 years, 9 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/c_format.py ('k') | grit/format/interface.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/format/data_pack.py
diff --git a/grit/format/data_pack.py b/grit/format/data_pack.py
index 7c31f2ea6a749c1f046f0553735a2af0c871eb41..e3234e87d2e1480b052b68aef843799307cfa978 100755
--- a/grit/format/data_pack.py
+++ b/grit/format/data_pack.py
@@ -34,10 +34,7 @@ class DataPackContents:
class DataPack(interface.ItemFormatter):
'''Writes out the data pack file format (platform agnostic resource file).'''
- def Format(self, item, lang='en', begin_item=True, output_dir='.'):
- if not begin_item:
- return ''
-
+ def Format(self, item, lang='en', output_dir='.'):
assert isinstance(item, misc.ReleaseNode)
nodes = DataPack.GetDataNodes(item)
@@ -157,12 +154,20 @@ class DataPack(interface.ItemFormatter):
DataPack.WriteDataPack(resources, output_file, encoding)
def main():
- # Just write a simple file.
- data = { 1: "", 4: "this is id 4", 6: "this is id 6", 10: "" }
- DataPack.WriteDataPack(data, "datapack1.pak", UTF8)
- data2 = { 1000: "test", 5: "five" }
- DataPack.WriteDataPack(data2, "datapack2.pak", UTF8)
- print "wrote datapack1 and datapack2 to current directory."
+ if len(sys.argv):
+ # When an argument is given, read and explode the file to text
+ # format, for easier diffing.
+ data = DataPack.ReadDataPack(sys.argv[1])
+ print data.encoding
+ for (resource_id, text) in data.resources.iteritems():
+ print "%s: %s" % (resource_id, text)
+ else:
+ # Just write a simple file.
+ data = { 1: "", 4: "this is id 4", 6: "this is id 6", 10: "" }
+ DataPack.WriteDataPack(data, "datapack1.pak", UTF8)
+ data2 = { 1000: "test", 5: "five" }
+ DataPack.WriteDataPack(data2, "datapack2.pak", UTF8)
+ print "wrote datapack1 and datapack2 to current directory."
if __name__ == '__main__':
main()
« no previous file with comments | « grit/format/c_format.py ('k') | grit/format/interface.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698