1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "chrome/browser/ui/webui/options/chromeos/language_pinyin_handler.h" 6 7 #include "base/values.h" 8 #include "chrome/browser/chromeos/language_preferences.h" 9 #include "chrome/browser/ui/webui/options/chromeos/language_options_util.h" 10 #include "grit/generated_resources.h" 11 #include "ui/base/l10n/l10n_util.h" 12 13 namespace { 14 const char kI18nPrefix[] = "Pinyin"; 15 } // namespace 16 17 namespace chromeos { 18 namespace options { 19 20 LanguagePinyinHandler::LanguagePinyinHandler() { 21 } 22 23 LanguagePinyinHandler::~LanguagePinyinHandler() { 24 } 25 26 void LanguagePinyinHandler::GetLocalizedValues( 27 DictionaryValue* localized_strings) { 28 DCHECK(localized_strings); 29 30 RegisterTitle(localized_strings, "languagePinyinPage", 31 IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTINGS_TITLE); 32 33 for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { 34 localized_strings->SetString( 35 GetI18nContentValue(language_prefs::kPinyinBooleanPrefs[i], 36 kI18nPrefix), 37 l10n_util::GetStringUTF16( 38 language_prefs::kPinyinBooleanPrefs[i].message_id)); 39 } 40 41 localized_strings->SetString( 42 GetI18nContentValue(language_prefs::kPinyinDoublePinyinSchema, 43 kI18nPrefix), 44 l10n_util::GetStringUTF16( 45 language_prefs::kPinyinDoublePinyinSchema.label_message_id)); 46 ListValue* list_value = new ListValue(); 47 for (size_t i = 0; 48 i < language_prefs::LanguageMultipleChoicePreference<int>::kMaxItems; 49 ++i) { 50 if (language_prefs::kPinyinDoublePinyinSchema.values_and_ids[i]. 51 item_message_id == 0) 52 break; 53 ListValue* option = new ListValue(); 54 option->Append(new base::FundamentalValue( 55 language_prefs::kPinyinDoublePinyinSchema.values_and_ids[i]. 56 ibus_config_value)); 57 option->Append(new base::StringValue(l10n_util::GetStringUTF16( 58 language_prefs::kPinyinDoublePinyinSchema.values_and_ids[i]. 59 item_message_id))); 60 list_value->Append(option); 61 } 62 localized_strings->Set( 63 GetTemplateDataPropertyName(language_prefs::kPinyinDoublePinyinSchema, 64 kI18nPrefix), 65 list_value); 66 } 67 68 } // namespace options 69 } // namespace chromeos 70