summaryrefslogtreecommitdiffstats
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
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
-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
-rw-r--r--webkit/glue/webkit_strings.grd2
-rw-r--r--webkit/tools/test_shell/SConscript3
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc138
6 files changed, 27 insertions, 139 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
diff --git a/webkit/glue/webkit_strings.grd b/webkit/glue/webkit_strings.grd
index 1c16d5f..61c2f5c 100644
--- a/webkit/glue/webkit_strings.grd
+++ b/webkit/glue/webkit_strings.grd
@@ -97,6 +97,8 @@ below:
<output filename="webkit_strings_vi.rc" type="rc_all" lang="vi" />
<output filename="webkit_strings_zh-CN.rc" type="rc_all" lang="zh-CN" />
<output filename="webkit_strings_zh-TW.rc" type="rc_all" lang="zh-TW" />
+
+ <output filename="webkit_strings_en-US.pak" type="data_package" lang="en" />
</outputs>
<translations>
<file path="resources/webkit_strings_ar.xtb" lang="ar" />
diff --git a/webkit/tools/test_shell/SConscript b/webkit/tools/test_shell/SConscript
index 45213a9..90291a1 100644
--- a/webkit/tools/test_shell/SConscript
+++ b/webkit/tools/test_shell/SConscript
@@ -211,8 +211,9 @@ if env.Bit('linux'):
test_shell_data = env.Repack(
'$TARGET_ROOT/test_shell.pak',
['$TARGET_ROOT/grit_derived_sources/net_resources.pak',
- '$TARGET_ROOT/grit_derived_sources/webkit_resources.pak',
'$TARGET_ROOT/grit_derived_sources/test_shell_resources.pak',
+ '$TARGET_ROOT/grit_derived_sources/webkit_resources.pak',
+ '$TARGET_ROOT/grit_derived_sources/webkit_strings_en-US.pak',
]
)
env.Depends(test_shell, test_shell_data)
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index f085393..7fe0796 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -31,10 +31,8 @@
#include "webkit/tools/test_shell/test_webview_delegate.h"
// Generated by GRIT
-#include "webkit_resources.h"
#include "test_shell_resources.h"
-// TODO(deanm): Needed for the localized string shim.
-#include "webkit_strings.h"
+#include "webkit_resources.h"
namespace {
@@ -678,139 +676,13 @@ StringPiece TestShell::NetResourceProvider(int key) {
namespace webkit_glue {
-// TODO(deanm): This is just a shim for now. We need to extend GRIT to do
-// proper resources on Linux, and figure out exactly how we'll do localization.
-// For now this is just a copy of webkit_strings_en-US.rc in switch form.
std::wstring GetLocalizedString(int message_id) {
- const char* str = NULL;
-
- switch (message_id) {
- case IDS_SEARCHABLE_INDEX_INTRO:
- str = "This is a searchable index. Enter search keywords: ";
- break;
- case IDS_FORM_SUBMIT_LABEL:
- str = "Submit";
- break;
- case IDS_FORM_INPUT_ALT:
- str = "Submit";
- break;
- case IDS_FORM_RESET_LABEL:
- str = "Reset";
- break;
- case IDS_FORM_FILE_BUTTON_LABEL:
- str = "Choose File";
- break;
- case IDS_FORM_FILE_NO_FILE_LABEL:
- str = "No file chosen";
- break;
- case IDS_FORM_FILE_NO_FILE_DRAG_LABEL:
- str = "Drag file here";
- break;
- case IDS_RECENT_SEARCHES_NONE:
- str = "No recent searches";
- break;
- case IDS_RECENT_SEARCHES:
- str = "Recent Searches";
- break;
- case IDS_RECENT_SEARCHES_CLEAR:
- str = "Clear Recent Searches";
- break;
- case IDS_IMAGE_TITLE_FOR_FILENAME:
- str = "%s%d\xc3\x97%d";
- break;
- case IDS_AX_ROLE_WEB_AREA:
- str = "web area";
- break;
- case IDS_AX_ROLE_LINK:
- str = "link";
- break;
- case IDS_AX_ROLE_LIST_MARKER:
- str = "list marker";
- break;
- case IDS_AX_ROLE_IMAGE_MAP:
- str = "image map";
- break;
- case IDS_AX_ROLE_HEADING:
- str = "heading";
- break;
- case IDS_AX_BUTTON_ACTION_VERB:
- str = "press";
- break;
- case IDS_AX_RADIO_BUTTON_ACTION_VERB:
- str = "select";
- break;
- case IDS_AX_TEXT_FIELD_ACTION_VERB:
- str = "activate";
- break;
- case IDS_AX_CHECKED_CHECK_BOX_ACTION_VERB:
- str = "uncheck";
- break;
- case IDS_AX_UNCHECKED_CHECK_BOX_ACTION_VERB:
- str = "check";
- break;
- case IDS_AX_LINK_ACTION_VERB:
- str = "jump";
- break;
- case IDS_KEYGEN_HIGH_GRADE_KEY:
- str = "2048 (High Grade)";
- break;
- case IDS_KEYGEN_MED_GRADE_KEY:
- str = "1024 (Medium Grade)";
- break;
- case IDS_DEFAULT_PLUGIN_GET_PLUGIN_MSG:
- str = "$1 plugin is not installed";
- break;
- case IDS_DEFAULT_PLUGIN_GET_PLUGIN_MSG_NO_PLUGIN_NAME:
- str = "The required plugin is not installed";
- break;
- case IDS_DEFAULT_PLUGIN_GET_PLUGIN_MSG_2:
- str = "Click here to download plugin";
- break;
- case IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG:
- str = "After installing the plugin, click here to refresh";
- break;
- case IDS_DEFAULT_PLUGIN_NO_PLUGIN_AVAILABLE_MSG:
- str = "No plugin available to display this content";
- break;
- case IDS_DEFAULT_PLUGIN_DOWNLOADING_PLUGIN_MSG:
- str = "Downloading plugin...";
- break;
- case IDS_DEFAULT_PLUGIN_GET_THE_PLUGIN_BTN_MSG:
- str = "Get Plugin";
- break;
- case IDS_DEFAULT_PLUGIN_CANCEL_PLUGIN_DOWNLOAD_MSG:
- str = "Cancel";
- break;
- case IDS_DEFAULT_PLUGIN_CONFIRMATION_DIALOG_TITLE:
- str = "$1 plugin needed";
- break;
- case IDS_DEFAULT_PLUGIN_CONFIRMATION_DIALOG_TITLE_NO_PLUGIN_NAME:
- str = "Additional plugin needed";
- break;
- case IDS_DEFAULT_PLUGIN_USER_OPTION_MSG:
- str = "Please confirm that you would like to install the $1 plugin. You should only install plugins that you trust.";
- break;
- case IDS_DEFAULT_PLUGIN_USER_OPTION_MSG_NO_PLUGIN_NAME:
- str = "Please confirm that you would like to install this plugin. You should only install plugins that you trust.";
- break;
- case IDS_DEFAULT_PLUGIN_USE_OPTION_CONFIRM:
- str = "Install";
- break;
- case IDS_DEFAULT_PLUGIN_USE_OPTION_CANCEL:
- str = "Cancel";
- break;
- case IDS_DEFAULT_PLUGIN_DOWNLOAD_FAILED_MSG:
- str = "Failed to install plugin from $1";
- break;
- case IDS_DEFAULT_PLUGIN_INSTALLATION_FAILED_MSG:
- str = "Plugin installation failed";
- break;
- default:
- NOTIMPLEMENTED();
- str = "No string for this identifier!";
+ StringPiece res;
+ if (!g_resource_data_pack->Get(message_id, &res)) {
+ LOG(FATAL) << "failed to load webkit string with id " << message_id;
}
- return UTF8ToWide(str);
+ return UTF8ToWide(res.as_string());
}
std::string GetDataResource(int resource_id) {