summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-22 01:24:08 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-22 01:24:08 +0000
commit5bc0feb22687326cc26214c100c4658c79ce314f (patch)
tree07f13f815259685f43c3f903feffe4a69a74af67 /tools
parentdfe1486216ccb5942ef52bafa30d361638183eea (diff)
downloadchromium_src-5bc0feb22687326cc26214c100c4658c79ce314f.zip
chromium_src-5bc0feb22687326cc26214c100c4658c79ce314f.tar.gz
chromium_src-5bc0feb22687326cc26214c100c4658c79ce314f.tar.bz2
Include webkit strings in test shell data pack.
This adds <message> node to the types of GRIT nodes that we can stuff into a data package file and removes a test shell hack. Review URL: http://codereview.chromium.org/18478 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8431 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rwxr-xr-xtools/grit/grit/format/data_pack.py9
-rw-r--r--tools/grit/grit/node/include.py2
-rw-r--r--tools/grit/grit/node/message.py12
3 files changed, 18 insertions, 5 deletions
diff --git a/tools/grit/grit/format/data_pack.py b/tools/grit/grit/format/data_pack.py
index 797c23e..f70b49b 100755
--- a/tools/grit/grit/format/data_pack.py
+++ b/tools/grit/grit/format/data_pack.py
@@ -10,8 +10,9 @@ files.
import struct
from grit.format import interface
-from grit.node import misc
from grit.node import include
+from grit.node import message
+from grit.node import misc
PACK_FILE_VERSION = 1
@@ -28,7 +29,7 @@ class DataPack(interface.ItemFormatter):
nodes = DataPack.GetDataNodes(item)
data = {}
for node in nodes:
- id, value = node.GetDataPackPair(output_dir)
+ id, value = node.GetDataPackPair(output_dir, lang)
data[id] = value
return DataPack.WriteDataPack(data)
@@ -36,9 +37,9 @@ class DataPack(interface.ItemFormatter):
def GetDataNodes(item):
'''Returns a list of nodes that can be packed into the data pack file.'''
nodes = []
- if isinstance(item, include.IncludeNode):
+ if (isinstance(item, include.IncludeNode) or
+ isinstance(item, message.MessageNode)):
return [item]
- # TODO(tc): Handle message nodes.
for child in item.children:
nodes.extend(DataPack.GetDataNodes(child))
return nodes
diff --git a/tools/grit/grit/node/include.py b/tools/grit/grit/node/include.py
index 6ff560a..47599a42 100644
--- a/tools/grit/grit/node/include.py
+++ b/tools/grit/grit/node/include.py
@@ -47,7 +47,7 @@ class IncludeNode(base.Node):
'''
return self.FilenameToOpen()
- def GetDataPackPair(self, output_dir):
+ def GetDataPackPair(self, output_dir, lang):
'''Returns a (id, string) pair that represents the resource id and raw
bytes of the data. This is used to generate the data pack data file.
'''
diff --git a/tools/grit/grit/node/message.py b/tools/grit/grit/node/message.py
index 3614362..66afa64 100644
--- a/tools/grit/grit/node/message.py
+++ b/tools/grit/grit/node/message.py
@@ -174,6 +174,18 @@ class MessageNode(base.ContentNode):
else:
return self.attrs['offset']
+ def GetDataPackPair(self, output_dir, lang):
+ '''Returns a (id, string) pair that represents the string id and the string
+ in utf8. This is used to generate the data pack data file.
+ '''
+ from grit.format import rc_header
+ id_map = rc_header.Item.tids_
+ id = id_map[self.GetTextualIds()[0]]
+
+ message = self.ws_at_start + self.Translate(lang) + self.ws_at_end
+ # |message| is a python unicode string, so convert to a utf8 byte stream.
+ return id, message.encode('utf8')
+
# static method
def Construct(parent, message, name, desc='', meaning='', translateable=True):
'''Constructs a new message node that is a child of 'parent', with the