OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 "components/login/localized_values_builder.h" |
| 6 |
| 7 #include "base/values.h" |
| 8 #include "ui/base/l10n/l10n_util.h" |
| 9 |
| 10 namespace login { |
| 11 |
| 12 LocalizedValuesBuilder::LocalizedValuesBuilder(base::DictionaryValue* dict) |
| 13 : dict_(dict) { |
| 14 } |
| 15 |
| 16 LocalizedValuesBuilder::LocalizedValuesBuilder(const std::string& prefix, |
| 17 base::DictionaryValue* dict) |
| 18 : prefix_(prefix), dict_(dict) { |
| 19 } |
| 20 |
| 21 void LocalizedValuesBuilder::Add(const std::string& key, |
| 22 const std::string& message) { |
| 23 dict_->SetString(prefix_ + key, message); |
| 24 } |
| 25 |
| 26 void LocalizedValuesBuilder::Add(const std::string& key, |
| 27 const base::string16& message) { |
| 28 dict_->SetString(prefix_ + key, message); |
| 29 } |
| 30 |
| 31 void LocalizedValuesBuilder::Add(const std::string& key, int message_id) { |
| 32 dict_->SetString(prefix_ + key, l10n_util::GetStringUTF16(message_id)); |
| 33 } |
| 34 |
| 35 void LocalizedValuesBuilder::AddF(const std::string& key, |
| 36 int message_id, |
| 37 const base::string16& a) { |
| 38 dict_->SetString(prefix_ + key, l10n_util::GetStringFUTF16(message_id, a)); |
| 39 } |
| 40 |
| 41 void LocalizedValuesBuilder::AddF(const std::string& key, |
| 42 int message_id, |
| 43 const base::string16& a, |
| 44 const base::string16& b) { |
| 45 dict_->SetString(prefix_ + key, l10n_util::GetStringFUTF16(message_id, a, b)); |
| 46 } |
| 47 |
| 48 void LocalizedValuesBuilder::AddF(const std::string& key, |
| 49 int message_id, |
| 50 int message_id_a) { |
| 51 AddF(key, message_id, l10n_util::GetStringUTF16(message_id_a)); |
| 52 } |
| 53 |
| 54 void LocalizedValuesBuilder::AddF(const std::string& key, |
| 55 int message_id, |
| 56 int message_id_a, |
| 57 int message_id_b) { |
| 58 AddF(key, message_id, l10n_util::GetStringUTF16(message_id_a), |
| 59 l10n_util::GetStringUTF16(message_id_b)); |
| 60 } |
| 61 |
| 62 } // namespace login |
OLD | NEW |