OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
please use gerrit instead
2014/06/05 22:22:49
Remove this localization.cc file! (It's not used i
please use gerrit instead
2014/06/09 23:28:17
Done.
| |
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 "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati on.h" | |
6 | |
7 #include <cassert> | |
8 #include <cstddef> | |
9 #include <string> | |
10 | |
11 #include "third_party/libaddressinput/src/cpp/src/grit.h" | |
12 | |
13 namespace i18n { | |
14 namespace addressinput { | |
15 | |
16 namespace { | |
17 | |
18 static const char kDefaultLanguage[] = "en"; | |
19 | |
20 // Only libaddressinput_unittests call this function, because they always use | |
21 // the default strings. | |
22 std::string NoDefaultStrings(int message_id) { | |
23 static const char kInvalidString[] = "[INVALID_STRING]"; | |
24 static const char kEmptyString[] = ""; | |
25 return message_id != INVALID_MESSAGE_ID ? kInvalidString : kEmptyString; | |
26 } | |
27 | |
28 } // namespace | |
29 | |
30 Localization::Localization() : get_string_(&NoDefaultStrings), | |
31 language_tag_(kDefaultLanguage) {} | |
32 | |
33 Localization::~Localization() {} | |
34 | |
35 std::string Localization::GetString(int message_id) const { | |
36 return get_string_(message_id); | |
37 } | |
38 | |
39 void Localization::SetLanguage(const std::string& language_tag) { | |
40 // Only libaddressinput_unittests call this function. | |
41 assert(language_tag == kDefaultLanguage); | |
42 language_tag_ = language_tag; | |
43 } | |
44 | |
45 void Localization::SetGetter(std::string (*getter)(int), | |
46 const std::string& language_tag) { | |
47 assert(getter != NULL); | |
48 get_string_ = getter; | |
49 language_tag_ = language_tag; | |
50 } | |
51 | |
52 } // namespace addressinput | |
53 } // namespace i18n | |
OLD | NEW |