summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/options/languages_page_view.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-24 20:14:16 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-24 20:14:16 +0000
commit1480c1f9c25ce91f827e28602d5de83e7e88b800 (patch)
treeae575e4a55fbc9052c1212d9f28db015623eca50 /chrome/browser/views/options/languages_page_view.cc
parent8a0098f59d6170cf0050d3ebd25b45ee77919137 (diff)
downloadchromium_src-1480c1f9c25ce91f827e28602d5de83e7e88b800.zip
chromium_src-1480c1f9c25ce91f827e28602d5de83e7e88b800.tar.gz
chromium_src-1480c1f9c25ce91f827e28602d5de83e7e88b800.tar.bz2
Switch some more ASCII locale code wstrings to strings.
Also, don't alphabetize available spellchecker locale codes. Review URL: http://codereview.chromium.org/42531 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12388 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/options/languages_page_view.cc')
-rw-r--r--chrome/browser/views/options/languages_page_view.cc352
1 files changed, 177 insertions, 175 deletions
diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc
index 0ed4f94..2634639 100644
--- a/chrome/browser/views/options/languages_page_view.cc
+++ b/chrome/browser/views/options/languages_page_view.cc
@@ -37,139 +37,138 @@
#include "skia/include/SkBitmap.h"
#include "unicode/uloc.h"
-// TODO(port): this should be a char* list.
-static const wchar_t* const accept_language_list[] = {
- L"af", // Afrikaans
- L"am", // Amharic
- L"ar", // Arabic
- L"az", // Azerbaijani
- L"be", // Belarusian
- L"bg", // Bulgarian
- L"bh", // Bihari
- L"bn", // Bengali
- L"br", // Breton
- L"bs", // Bosnian
- L"ca", // Catalan
- L"co", // Corsican
- L"cs", // Czech
- L"cy", // Welsh
- L"da", // Danish
- L"de", // German
- L"de-AT", // German (Austria)
- L"de-CH", // German (Switzerland)
- L"de-DE", // German (Germany)
- L"el", // Greek
- L"en", // English
- L"en-AU", // English (Austrailia)
- L"en-CA", // English (Canada)
- L"en-GB", // English (UK)
- L"en-NZ", // English (New Zealand)
- L"en-US", // English (US)
- L"en-ZA", // English (South Africa)
- L"eo", // Esperanto
+static const char* const accept_language_list[] = {
+ "af", // Afrikaans
+ "am", // Amharic
+ "ar", // Arabic
+ "az", // Azerbaijani
+ "be", // Belarusian
+ "bg", // Bulgarian
+ "bh", // Bihari
+ "bn", // Bengali
+ "br", // Breton
+ "bs", // Bosnian
+ "ca", // Catalan
+ "co", // Corsican
+ "cs", // Czech
+ "cy", // Welsh
+ "da", // Danish
+ "de", // German
+ "de-AT", // German (Austria)
+ "de-CH", // German (Switzerland)
+ "de-DE", // German (Germany)
+ "el", // Greek
+ "en", // English
+ "en-AU", // English (Austrailia)
+ "en-CA", // English (Canada)
+ "en-GB", // English (UK)
+ "en-NZ", // English (New Zealand)
+ "en-US", // English (US)
+ "en-ZA", // English (South Africa)
+ "eo", // Esperanto
// TODO(jungshik) : Do we want to list all es-Foo for Latin-American
// Spanish speaking countries?
- L"es", // Spanish
- L"et", // Estonian
- L"eu", // Basque
- L"fa", // Persian
- L"fi", // Finnish
- L"fil", // Filipino
- L"fo", // Faroese
- L"fr", // French
- L"fr-CA", // French (Canada)
- L"fr-CH", // French (Switzerland)
- L"fr-FR", // French (France)
- L"fy", // Frisian
- L"ga", // Irish
- L"gd", // Scots Gaelic
- L"gl", // Galician
- L"gn", // Guarani
- L"gu", // Gujarati
- L"he", // Hebrew
- L"hi", // Hindi
- L"hr", // Croatian
- L"hu", // Hungarian
- L"hy", // Armenian
- L"ia", // Interlingua
- L"id", // Indonesian
- L"is", // Icelandic
- L"it", // Italian
- L"it-CH", // Italian (Switzerland)
- L"it-IT", // Italian (Italy)
- L"ja", // Japanese
- L"jw", // Javanese
- L"ka", // Georgian
- L"kk", // Kazakh
- L"km", // Cambodian
- L"kn", // Kannada
- L"ko", // Korean
- L"ku", // Kurdish
- L"ky", // Kyrgyz
- L"la", // Latin
- L"ln", // Lingala
- L"lo", // Laothian
- L"lt", // Lithuanian
- L"lv", // Latvian
- L"mk", // Macedonian
- L"ml", // Malayalam
- L"mn", // Mongolian
- L"mo", // Moldavian
- L"mr", // Marathi
- L"ms", // Malay
- L"mt", // Maltese
- L"nb", // Norwegian (Bokmal)
- L"ne", // Nepali
- L"nl", // Dutch
- L"nn", // Norwegian (Nynorsk)
- L"no", // Norwegian
- L"oc", // Occitan
- L"or", // Oriya
- L"pa", // Punjabi
- L"pl", // Polish
- L"ps", // Pashto
- L"pt", // Portuguese
- L"pt-BR", // Portuguese (Brazil)
- L"pt-PT", // Portuguese (Portugal)
- L"qu", // Quechua
- L"rm", // Romansh
- L"ro", // Romanian
- L"ru", // Russian
- L"sd", // Sindhi
- L"sh", // Serbo-Croatian
- L"si", // Sinhalese
- L"sk", // Slovak
- L"sl", // Slovenian
- L"sn", // Shona
- L"so", // Somali
- L"sq", // Albanian
- L"sr", // Serbian
- L"st", // Sesotho
- L"su", // Sundanese
- L"sv", // Swedish
- L"sw", // Swahili
- L"ta", // Tamil
- L"te", // Telugu
- L"tg", // Tajik
- L"th", // Thai
- L"ti", // Tigrinya
- L"tk", // Turkmen
- L"to", // Tonga
- L"tr", // Turkish
- L"tt", // Tatar
- L"tw", // Twi
- L"ug", // Uighur
- L"uk", // Ukrainian
- L"ur", // Urdu
- L"uz", // Uzbek
- L"vi", // Vietnamese
- L"xh", // Xhosa
- L"yi", // Yiddish
- L"yo", // Yoruba
- L"zh", // Chinese
- L"zh-CN", // Chinese (Simplified)
- L"zh-TW", // Chinese (Traditional)
- L"zu", // Zulu
+ "es", // Spanish
+ "et", // Estonian
+ "eu", // Basque
+ "fa", // Persian
+ "fi", // Finnish
+ "fil", // Filipino
+ "fo", // Faroese
+ "fr", // French
+ "fr-CA", // French (Canada)
+ "fr-CH", // French (Switzerland)
+ "fr-FR", // French (France)
+ "fy", // Frisian
+ "ga", // Irish
+ "gd", // Scots Gaelic
+ "gl", // Galician
+ "gn", // Guarani
+ "gu", // Gujarati
+ "he", // Hebrew
+ "hi", // Hindi
+ "hr", // Croatian
+ "hu", // Hungarian
+ "hy", // Armenian
+ "ia", // Interlingua
+ "id", // Indonesian
+ "is", // Icelandic
+ "it", // Italian
+ "it-CH", // Italian (Switzerland)
+ "it-IT", // Italian (Italy)
+ "ja", // Japanese
+ "jw", // Javanese
+ "ka", // Georgian
+ "kk", // Kazakh
+ "km", // Cambodian
+ "kn", // Kannada
+ "ko", // Korean
+ "ku", // Kurdish
+ "ky", // Kyrgyz
+ "la", // Latin
+ "ln", // Lingala
+ "lo", // Laothian
+ "lt", // Lithuanian
+ "lv", // Latvian
+ "mk", // Macedonian
+ "ml", // Malayalam
+ "mn", // Mongolian
+ "mo", // Moldavian
+ "mr", // Marathi
+ "ms", // Malay
+ "mt", // Maltese
+ "nb", // Norwegian (Bokmal)
+ "ne", // Nepali
+ "nl", // Dutch
+ "nn", // Norwegian (Nynorsk)
+ "no", // Norwegian
+ "oc", // Occitan
+ "or", // Oriya
+ "pa", // Punjabi
+ "pl", // Polish
+ "ps", // Pashto
+ "pt", // Portuguese
+ "pt-BR", // Portuguese (Brazil)
+ "pt-PT", // Portuguese (Portugal)
+ "qu", // Quechua
+ "rm", // Romansh
+ "ro", // Romanian
+ "ru", // Russian
+ "sd", // Sindhi
+ "sh", // Serbo-Croatian
+ "si", // Sinhalese
+ "sk", // Slovak
+ "sl", // Slovenian
+ "sn", // Shona
+ "so", // Somali
+ "sq", // Albanian
+ "sr", // Serbian
+ "st", // Sesotho
+ "su", // Sundanese
+ "sv", // Swedish
+ "sw", // Swahili
+ "ta", // Tamil
+ "te", // Telugu
+ "tg", // Tajik
+ "th", // Thai
+ "ti", // Tigrinya
+ "tk", // Turkmen
+ "to", // Tonga
+ "tr", // Turkish
+ "tt", // Tatar
+ "tw", // Twi
+ "ug", // Uighur
+ "uk", // Ukrainian
+ "ur", // Urdu
+ "uz", // Uzbek
+ "vi", // Vietnamese
+ "xh", // Xhosa
+ "yi", // Yiddish
+ "yo", // Yoruba
+ "zh", // Chinese
+ "zh-CN", // Chinese (Simplified)
+ "zh-TW", // Chinese (Traditional)
+ "zu", // Zulu
};
///////////////////////////////////////////////////////////////////////////////
@@ -216,7 +215,7 @@ class AddLanguageWindowView : public views::View,
// Used for Call back to LanguagePageView that language has been selected.
LanguagesPageView* language_delegate_;
- std::wstring accept_language_selected_;
+ std::string accept_language_selected_;
// Combobox and its corresponding model.
scoped_ptr<LanguageComboboxModel> accept_language_combobox_model_;
@@ -225,7 +224,7 @@ class AddLanguageWindowView : public views::View,
// The Profile associated with this window.
Profile* profile_;
- DISALLOW_EVIL_CONSTRUCTORS(AddLanguageWindowView);
+ DISALLOW_COPY_AND_ASSIGN(AddLanguageWindowView);
};
static const int kDialogPadding = 7;
@@ -288,7 +287,7 @@ void AddLanguageWindowView::ViewHierarchyChanged(bool is_add,
void AddLanguageWindowView::Init() {
// Determine Locale Codes.
- std::vector<std::wstring> locale_codes;
+ std::vector<std::string> locale_codes;
const std::wstring app_locale = g_browser_process->GetApplicationLocale();
for (size_t i = 0; i < arraysize(accept_language_list); ++i) {
std::wstring local_name =
@@ -298,8 +297,10 @@ void AddLanguageWindowView::Init() {
// In that case, we skip it.
// TODO(jungshik) : Put them at the of the list with language codes
// enclosed by brackets.
- if (local_name != accept_language_list[i])
- locale_codes.push_back(accept_language_list[i]);
+ if (IsStringASCII(local_name) &&
+ WideToASCII(local_name) == accept_language_list[i])
+ continue;
+ locale_codes.push_back(accept_language_list[i]);
}
accept_language_combobox_model_.reset(new LanguageComboboxModel(
profile_, locale_codes));
@@ -315,17 +316,17 @@ class LanguageOrderTableModel : public views::TableModel {
LanguageOrderTableModel();
// Set Language List.
- void SetAcceptLanguagesString(const std::wstring& language_list);
+ void SetAcceptLanguagesString(const std::string& language_list);
// Add at the end.
- void Add(const std::wstring& language);
+ void Add(const std::string& language);
// Removes the entry at the specified index.
void Remove(int index);
// Returns index corresponding to a given language. Returns -1 if the
// language is not found.
- int GetIndex(const std::wstring& language);
+ int GetIndex(const std::string& language);
// Move down the entry at the specified index.
void MoveDown(int index);
@@ -334,7 +335,7 @@ class LanguageOrderTableModel : public views::TableModel {
void MoveUp(int index);
// Returns the set of languagess this model contains.
- std::wstring GetLanguageList() { return VectorToList(languages_); }
+ std::string GetLanguageList() { return VectorToList(languages_); }
// views::TableModel overrides:
virtual int RowCount();
@@ -343,19 +344,19 @@ class LanguageOrderTableModel : public views::TableModel {
private:
// This method converts a comma separated list to a vector of strings.
- void ListToVector(const std::wstring& list,
- std::vector<std::wstring>* vector);
+ void ListToVector(const std::string& list,
+ std::vector<std::string>* vector);
// This method returns a comma separated string given a string vector.
- std::wstring VectorToList(const std::vector<std::wstring>& vector);
+ std::string VectorToList(const std::vector<std::string>& vector);
// Set of entries we're showing.
- std::vector<std::wstring> languages_;
- std::wstring comma_separated_language_list_;
+ std::vector<std::string> languages_;
+ std::string comma_separated_language_list_;
views::TableModelObserver* observer_;
- DISALLOW_EVIL_CONSTRUCTORS(LanguageOrderTableModel);
+ DISALLOW_COPY_AND_ASSIGN(LanguageOrderTableModel);
};
LanguageOrderTableModel::LanguageOrderTableModel()
@@ -363,8 +364,8 @@ LanguageOrderTableModel::LanguageOrderTableModel()
}
void LanguageOrderTableModel::SetAcceptLanguagesString(
- const std::wstring& language_list) {
- std::vector<std::wstring> languages_vector;
+ const std::string& language_list) {
+ std::vector<std::string> languages_vector;
ListToVector(language_list, &languages_vector);
for (int i = 0; i < static_cast<int>(languages_vector.size()); i++) {
Add(languages_vector.at(i));
@@ -382,11 +383,11 @@ std::wstring LanguageOrderTableModel::GetText(int row, int column_id) {
return l10n_util::GetLocalName(languages_.at(row), app_locale, true);
}
-void LanguageOrderTableModel::Add(const std::wstring& language) {
+void LanguageOrderTableModel::Add(const std::string& language) {
if (language.empty())
return;
// Check for selecting duplicated language.
- for (std::vector<std::wstring>::const_iterator cit = languages_.begin();
+ for (std::vector<std::string>::const_iterator cit = languages_.begin();
cit != languages_.end(); ++cit)
if (*cit == language)
return;
@@ -402,12 +403,12 @@ void LanguageOrderTableModel::Remove(int index) {
observer_->OnItemsRemoved(index, 1);
}
-int LanguageOrderTableModel::GetIndex(const std::wstring& language) {
+int LanguageOrderTableModel::GetIndex(const std::string& language) {
if (language.empty())
return -1;
int index = 0;
- for (std::vector<std::wstring>::const_iterator cit = languages_.begin();
+ for (std::vector<std::string>::const_iterator cit = languages_.begin();
cit != languages_.end(); ++cit) {
if (*cit == language)
return index;
@@ -421,7 +422,7 @@ int LanguageOrderTableModel::GetIndex(const std::wstring& language) {
void LanguageOrderTableModel::MoveDown(int index) {
if (index < 0 || index >= RowCount() - 1)
return;
- std::wstring item = languages_.at(index);
+ std::string item = languages_.at(index);
languages_.erase(languages_.begin() + index);
if (index == RowCount() - 1)
languages_.push_back(item);
@@ -434,7 +435,7 @@ void LanguageOrderTableModel::MoveDown(int index) {
void LanguageOrderTableModel::MoveUp(int index) {
if (index <= 0 || index >= static_cast<int>(languages_.size()))
return;
- std::wstring item = languages_.at(index);
+ std::string item = languages_.at(index);
languages_.erase(languages_.begin() + index);
languages_.insert(languages_.begin() + index - 1, item);
if (observer_)
@@ -445,14 +446,14 @@ int LanguageOrderTableModel::RowCount() {
return static_cast<int>(languages_.size());
}
-void LanguageOrderTableModel::ListToVector(const std::wstring& list,
- std::vector<std::wstring>* vector) {
- SplitString(list, L',', vector);
+void LanguageOrderTableModel::ListToVector(const std::string& list,
+ std::vector<std::string>* vector) {
+ SplitString(list, ',', vector);
}
-std::wstring LanguageOrderTableModel::VectorToList(
- const std::vector<std::wstring>& vector) {
- std::wstring list;
+std::string LanguageOrderTableModel::VectorToList(
+ const std::vector<std::string>& vector) {
+ std::string list;
for (int i = 0 ; i < static_cast<int>(vector.size()) ; i++) {
list += vector.at(i);
if (i != vector.size() - 1)
@@ -517,7 +518,7 @@ void LanguagesPageView::ButtonPressed(views::Button* sender) {
}
}
-void LanguagesPageView::OnAddLanguage(const std::wstring& new_language) {
+void LanguagesPageView::OnAddLanguage(const std::string& new_language) {
language_order_table_model_->Add(new_language);
language_order_table_->Select(language_order_table_model_->RowCount() - 1);
OnSelectionChanged();
@@ -675,7 +676,7 @@ void LanguagesPageView::InitControlLayout() {
void LanguagesPageView::NotifyPrefChanged(const std::wstring* pref_name) {
if (!pref_name || *pref_name == prefs::kAcceptLanguages) {
language_order_table_model_->SetAcceptLanguagesString(
- accept_languages_.GetValue());
+ WideToASCII(accept_languages_.GetValue()));
}
if (!pref_name || *pref_name == prefs::kApplicationLocale) {
int index = ui_language_model_->GetSelectedLanguageIndex(
@@ -684,7 +685,7 @@ void LanguagesPageView::NotifyPrefChanged(const std::wstring* pref_name) {
// The pref value for locale isn't valid. Use the current app locale
// (which is what we're currently using).
index = ui_language_model_->GetIndexFromLocale(
- g_browser_process->GetApplicationLocale());
+ WideToASCII(g_browser_process->GetApplicationLocale()));
}
DCHECK(-1 != index);
change_ui_language_combobox_->SetSelectedItem(index);
@@ -712,11 +713,10 @@ void LanguagesPageView::NotifyPrefChanged(const std::wstring* pref_name) {
local_state = profile()->GetPrefs();
DCHECK(local_state);
- const std::wstring& lang_region = local_state->GetString(
- prefs::kSpellCheckDictionary);
+ const std::string& lang_region = WideToASCII(
+ local_state->GetString(prefs::kSpellCheckDictionary));
dictionary_language_.SetValue(ASCIIToWide(
- SpellChecker::GetLanguageFromLanguageRegion(
- WideToASCII(lang_region))));
+ SpellChecker::GetLanguageFromLanguageRegion(lang_region)));
index = dictionary_language_model_->GetSelectedLanguageIndex(
prefs::kSpellCheckDictionary);
}
@@ -760,7 +760,7 @@ void LanguagesPageView::ItemChanged(views::ComboBox* sender,
// Add this new spell check language only if it is not already in the
// accept language list.
- std::wstring language =
+ std::string language =
dictionary_language_model_->GetLocaleFromIndex(new_index);
int index = language_order_table_model_->GetIndex(language);
if (index == -1) {
@@ -769,7 +769,7 @@ void LanguagesPageView::ItemChanged(views::ComboBox* sender,
language_table_edited_ = true;
spellcheck_language_added_ = language;
} else {
- spellcheck_language_added_ = L"";
+ spellcheck_language_added_ = "";
}
}
}
@@ -821,14 +821,16 @@ void LanguagesPageView::OnMoveUpLanguage() {
}
void LanguagesPageView::SaveChanges() {
- if (language_order_table_model_.get() && language_table_edited_)
- accept_languages_.SetValue(language_order_table_model_->GetLanguageList());
+ if (language_order_table_model_.get() && language_table_edited_) {
+ accept_languages_.SetValue(ASCIIToWide(
+ language_order_table_model_->GetLanguageList()));
+ }
if (ui_language_index_selected_ != -1) {
UserMetricsRecordAction(L"Options_AppLanguage",
g_browser_process->local_state());
- app_locale_.SetValue(ui_language_model_->
- GetLocaleFromIndex(ui_language_index_selected_));
+ app_locale_.SetValue(ASCIIToWide(ui_language_model_->
+ GetLocaleFromIndex(ui_language_index_selected_)));
// Remove pref values for spellcheck dictionaries forcefully.
PrefService* prefs = profile()->GetPrefs();
@@ -839,7 +841,7 @@ void LanguagesPageView::SaveChanges() {
if (spellcheck_language_index_selected_ != -1) {
UserMetricsRecordAction(L"Options_DictionaryLanguage",
profile()->GetPrefs());
- dictionary_language_.SetValue(dictionary_language_model_->
- GetLocaleFromIndex(spellcheck_language_index_selected_));
+ dictionary_language_.SetValue(ASCIIToWide(dictionary_language_model_->
+ GetLocaleFromIndex(spellcheck_language_index_selected_)));
}
}