summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 07:35:44 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 07:35:44 +0000
commitf79cc024016c38c4531229fe343945fc9e3deb23 (patch)
treebf00df88e891330dd3314a3ccafc00ddbf9d89fa /chrome
parentb19af67cd03e15ccdec8ed6e6d37fd1773c640fd (diff)
downloadchromium_src-f79cc024016c38c4531229fe343945fc9e3deb23.zip
chromium_src-f79cc024016c38c4531229fe343945fc9e3deb23.tar.gz
chromium_src-f79cc024016c38c4531229fe343945fc9e3deb23.tar.bz2
Add ability to show "Chromium OS cannot be displayed" as needed.
In Chromium OS, there are languages that have input methods and/or keyboard layouts but not supported as UI language (ex. Norwegian at this moment). For these languages, we'll show this label until it's supported. TEST=manually; added a unit test. BUG=chromium-os:4573 Review URL: http://codereview.chromium.org/3131002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55685 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd4
-rw-r--r--chrome/browser/chromeos/dom_ui/language_options_handler.cc15
-rw-r--r--chrome/browser/chromeos/dom_ui/language_options_handler.h8
-rw-r--r--chrome/browser/chromeos/dom_ui/language_options_handler_unittest.cc9
-rw-r--r--chrome/browser/resources/options/chromeos_language_options.js12
5 files changed, 46 insertions, 2 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index ac8c0bf..7ff3689 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -8602,6 +8602,10 @@ Keep your key file in a safe place. You will need it to create new versions of y
desc="The label for a language that is currently used for UI">
<ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph> is displayed in this language
</message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_CANNOT_BE_DISPLAYED_IN_THIS_LANGUAGE"
+ desc="The label for a language that cannot be used for UI">
+ <ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph> cannot be displayed in this language
+ </message>
<message name="IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_STANDARD_INPUT_METHOD"
desc="The label for a input method">
Standard input method
diff --git a/chrome/browser/chromeos/dom_ui/language_options_handler.cc b/chrome/browser/chromeos/dom_ui/language_options_handler.cc
index 31df924..126d3a1 100644
--- a/chrome/browser/chromeos/dom_ui/language_options_handler.cc
+++ b/chrome/browser/chromeos/dom_ui/language_options_handler.cc
@@ -44,6 +44,10 @@ void LanguageOptionsHandler::GetLocalizedValues(
l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_LANGUAGES));
localized_strings->SetString(L"remove_button",
l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_REMOVE_BUTTON));
+ localized_strings->SetString(L"cannot_be_displayed_in_this_language",
+ l10n_util::GetStringF(
+ IDS_OPTIONS_SETTINGS_LANGUAGES_CANNOT_BE_DISPLAYED_IN_THIS_LANGUAGE,
+ l10n_util::GetString(IDS_PRODUCT_OS_NAME)));
localized_strings->SetString(L"is_displayed_in_this_language",
l10n_util::GetStringF(
IDS_OPTIONS_SETTINGS_LANGUAGES_IS_DISPLAYED_IN_THIS_LANGUAGE,
@@ -64,6 +68,7 @@ void LanguageOptionsHandler::GetLocalizedValues(
UTF8ToWide(g_browser_process->GetApplicationLocale()));
localized_strings->Set(L"inputMethodList", GetInputMethodList(*descriptors));
localized_strings->Set(L"languageList", GetLanguageList(*descriptors));
+ localized_strings->Set(L"uiLanguageCodeSet", GetUiLanguageCodeSet());
}
void LanguageOptionsHandler::RegisterMessages() {
@@ -152,6 +157,16 @@ ListValue* LanguageOptionsHandler::GetLanguageList(
return language_list;
}
+DictionaryValue* LanguageOptionsHandler::GetUiLanguageCodeSet() {
+ DictionaryValue* dictionary = new DictionaryValue();
+ const std::vector<std::string>& available_locales =
+ l10n_util::GetAvailableLocales();
+ for (size_t i = 0; i < available_locales.size(); ++i) {
+ dictionary->SetBoolean(available_locales[i], true);
+ }
+ return dictionary;
+}
+
void LanguageOptionsHandler::UiLanguageChangeCallback(
const Value* value) {
if (!value || !value->IsType(Value::TYPE_LIST)) {
diff --git a/chrome/browser/chromeos/dom_ui/language_options_handler.h b/chrome/browser/chromeos/dom_ui/language_options_handler.h
index c7fb204..f56c6a8 100644
--- a/chrome/browser/chromeos/dom_ui/language_options_handler.h
+++ b/chrome/browser/chromeos/dom_ui/language_options_handler.h
@@ -40,6 +40,14 @@ class LanguageOptionsHandler : public OptionsPageUIHandler {
// ...]
static ListValue* GetLanguageList(const InputMethodDescriptors& descriptors);
+ // Gets the set of language codes that can be used as UI language.
+ // The return value will look like:
+ // {'en-US': true, 'fi': true, 'fr': true, ...}
+ //
+ // Note that true in languageCodeSet does not mean anything. We just use
+ // the dictionary as a set.
+ static DictionaryValue* GetUiLanguageCodeSet();
+
private:
// Called when the UI language is changed.
// |value| will be the language code as string (ex. "fr").
diff --git a/chrome/browser/chromeos/dom_ui/language_options_handler_unittest.cc b/chrome/browser/chromeos/dom_ui/language_options_handler_unittest.cc
index 4c92766..31df240 100644
--- a/chrome/browser/chromeos/dom_ui/language_options_handler_unittest.cc
+++ b/chrome/browser/chromeos/dom_ui/language_options_handler_unittest.cc
@@ -149,4 +149,13 @@ TEST(LanguageOptionsHandlerTest, GetLanguageList) {
native_display_name);
}
+TEST(LanguageOptionsHandlerTest, GetUiLanguageCodeSet) {
+ scoped_ptr<DictionaryValue> dictionary(
+ LanguageOptionsHandler::GetUiLanguageCodeSet());
+ EXPECT_TRUE(dictionary->HasKey("en-US"));
+ // Note that we don't test a false case, as such an expectation will
+ // fail when we add support for the language.
+ // EXPECT_FALSE(dictionary->HasKey("no"));
+}
+
} // namespace chromeos
diff --git a/chrome/browser/resources/options/chromeos_language_options.js b/chrome/browser/resources/options/chromeos_language_options.js
index 31df274..eb89650 100644
--- a/chrome/browser/resources/options/chromeos_language_options.js
+++ b/chrome/browser/resources/options/chromeos_language_options.js
@@ -192,8 +192,9 @@ cr.define('options', function() {
uiLanguageButton.className = 'text-button';
// Remove the event listner.
uiLanguageButton.onclick = undefined;
- } else {
- // Otherwise, users can click on the button to change the UI language.
+ } else if (languageCode in templateData.uiLanguageCodeSet) {
+ // If the language is supported as UI language, users can click on
+ // the button to change the UI language.
uiLanguageButton.textContent =
localStrings.getString('display_in_this_language');
uiLanguageButton.className = '';
@@ -201,6 +202,13 @@ cr.define('options', function() {
uiLanguageButton.onclick = function(e) {
chrome.send('uiLanguageChange', [languageCode]);
}
+ } else {
+ // If the language is not supported as UI language, the button
+ // just says that Chromium OS cannot be displayed in this language.
+ uiLanguageButton.textContent =
+ localStrings.getString('cannot_be_displayed_in_this_language');
+ uiLanguageButton.className = 'text-button';
+ uiLanguageButton.onclick = undefined;
}
},