summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-18 22:34:36 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-18 22:34:36 +0000
commite4feed08884b1b1bd3af3986e56ca60c3d62a7da (patch)
treebbfa158eb296bb9e5b329efac64e3b8e36a7b3eb
parent70b45efc15674aa7241bbb95dc81b3019eac294b (diff)
downloadchromium_src-e4feed08884b1b1bd3af3986e56ca60c3d62a7da.zip
chromium_src-e4feed08884b1b1bd3af3986e56ca60c3d62a7da.tar.gz
chromium_src-e4feed08884b1b1bd3af3986e56ca60c3d62a7da.tar.bz2
Try to land strings on linux again (r9972). This time, enable
the resource bundle on linux unittests and make the unit_tests executable require the various .pak files. Review URL: http://codereview.chromium.org/20471 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9984 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/chrome_resources.scons1
-rw-r--r--chrome/app/chrome_strings.scons1
-rw-r--r--chrome/app/theme/theme_dll.scons1
-rw-r--r--chrome/common/l10n_util.cc8
-rw-r--r--chrome/common/resource_bundle_linux.cc17
-rw-r--r--chrome/test/unit/chrome_test_suite.h6
6 files changed, 25 insertions, 9 deletions
diff --git a/chrome/app/chrome_resources.scons b/chrome/app/chrome_resources.scons
index 6d0d32c..fdb8436 100644
--- a/chrome/app/chrome_resources.scons
+++ b/chrome/app/chrome_resources.scons
@@ -32,3 +32,4 @@ if env.Bit('linux'):
)
i = env.Install('$DESTINATION_ROOT', chrome_pak)
env.Requires('$DESTINATION_ROOT/chrome', i)
+ env.Requires('$DESTINATION_ROOT/unit_tests', i)
diff --git a/chrome/app/chrome_strings.scons b/chrome/app/chrome_strings.scons
index 2b5934e..562ef54 100644
--- a/chrome/app/chrome_strings.scons
+++ b/chrome/app/chrome_strings.scons
@@ -33,3 +33,4 @@ if env.Bit('linux'):
)
i = env.Install('$DESTINATION_ROOT/locales', lang_pak)
env.Requires('$DESTINATION_ROOT/chrome', i)
+ env.Requires('$DESTINATION_ROOT/unit_tests', i)
diff --git a/chrome/app/theme/theme_dll.scons b/chrome/app/theme/theme_dll.scons
index d99f9ee..9264c12 100644
--- a/chrome/app/theme/theme_dll.scons
+++ b/chrome/app/theme/theme_dll.scons
@@ -17,3 +17,4 @@ if env.Bit('linux'):
)
i = env.Install('$DESTINATION_ROOT/themes/', theme_default_pak)
env.Requires('$DESTINATION_ROOT/chrome', i)
+ env.Requires('$DESTINATION_ROOT/unit_tests', i)
diff --git a/chrome/common/l10n_util.cc b/chrome/common/l10n_util.cc
index dbe34c7..a8749c8 100644
--- a/chrome/common/l10n_util.cc
+++ b/chrome/common/l10n_util.cc
@@ -17,9 +17,11 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/gfx/chrome_canvas.h"
-#if defined(OS_WIN)
+#if defined(OS_WIN) || defined(OS_LINUX)
// TODO(port): re-enable.
#include "chrome/common/resource_bundle.h"
+#endif
+#if defined(OS_WIN)
#include "chrome/views/view.h"
#endif // defined(OS_WIN)
#include "unicode/coll.h"
@@ -325,7 +327,7 @@ std::wstring GetLocalName(const std::wstring& locale_code_wstr,
}
std::wstring GetString(int message_id) {
-#if defined(OS_WIN)
+#if defined(OS_WIN) || defined(OS_LINUX)
ResourceBundle &rb = ResourceBundle::GetSharedInstance();
return rb.GetLocalizedString(message_id);
#else
@@ -341,7 +343,7 @@ static std::wstring GetStringF(int message_id,
const std::wstring& c,
const std::wstring& d,
std::vector<size_t>* offsets) {
-#if defined(OS_WIN)
+#if defined(OS_WIN) || defined(OS_LINUX)
// TODO(port): re-enable.
const std::wstring& format_string = GetString(message_id);
std::wstring formatted = ReplaceStringPlaceholders(format_string, a, b, c,
diff --git a/chrome/common/resource_bundle_linux.cc b/chrome/common/resource_bundle_linux.cc
index 1cb8307..12b0858 100644
--- a/chrome/common/resource_bundle_linux.cc
+++ b/chrome/common/resource_bundle_linux.cc
@@ -37,7 +37,15 @@ void ResourceBundle::LoadResources(const std::wstring& pref_locale) {
bool success = resources_data_->Load(resources_data_path);
DCHECK(success) << "failed to load chrome.pak";
- // TODO(tc): Load the .pak file for locale_resources_data_.
+ FilePath locale_path;
+ PathService::Get(chrome::DIR_LOCALES, &locale_path);
+ // TODO(tc): Handle other locales properly.
+ NOTIMPLEMENTED() << " loading en-US strings only";
+ locale_path = locale_path.Append(FILE_PATH_LITERAL("en-US.pak"));
+ DCHECK(locale_resources_data_ == NULL) << "locale data already loaded!";
+ locale_resources_data_ = new base::DataPack;
+ success = locale_resources_data_->Load(locale_path);
+ DCHECK(success) << "failed to load locale pak file";
}
FilePath ResourceBundle::GetLocaleFilePath(const std::wstring& pref_locale) {
@@ -100,6 +108,9 @@ std::wstring ResourceBundle::GetLocalizedString(int message_id) {
return std::wstring();
}
}
- // Copy into a wstring and return.
- return UTF8ToWide(data.as_string());
+
+ // Data pack encodes strings as UTF16.
+ string16 msg(reinterpret_cast<const char16*>(data.data()),
+ data.length() / 2);
+ return UTF16ToWide(msg);
}
diff --git a/chrome/test/unit/chrome_test_suite.h b/chrome/test/unit/chrome_test_suite.h
index 705960b..79c5e19 100644
--- a/chrome/test/unit/chrome_test_suite.h
+++ b/chrome/test/unit/chrome_test_suite.h
@@ -15,7 +15,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
-#if defined(OS_WIN)
+#if defined(OS_WIN) || defined(OS_LINUX)
// TODO(port): Remove the #ifdef when ResourceBundle is ported.
#include "chrome/common/resource_bundle.h"
#endif
@@ -49,7 +49,7 @@ protected:
if (!user_data_dir.empty())
PathService::Override(chrome::DIR_USER_DATA, user_data_dir);
-#if defined(OS_WIN)
+#if defined(OS_WIN) || defined(OS_LINUX)
// TODO(port): Remove the #ifdef when ResourceBundle is ported.
//
// Force unittests to run using en-us so if we test against string
@@ -67,7 +67,7 @@ protected:
}
virtual void Shutdown() {
-#if defined(OS_WIN)
+#if defined(OS_WIN) || defined(OS_LINUX)
// TODO(port): Remove the #ifdef when ResourceBundle is ported.
ResourceBundle::CleanupSharedInstance();
#endif