OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/extensions/extension_l10n_util.h" | 5 #include "chrome/common/extensions/extension_l10n_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 base::Value* dictionary = messages_serializer.Deserialize(NULL, error); | 43 base::Value* dictionary = messages_serializer.Deserialize(NULL, error); |
44 if (!dictionary) { | 44 if (!dictionary) { |
45 if (error->empty()) { | 45 if (error->empty()) { |
46 // JSONFileValueSerializer just returns NULL if file cannot be found. It | 46 // JSONFileValueSerializer just returns NULL if file cannot be found. It |
47 // doesn't set the error, so we have to do it. | 47 // doesn't set the error, so we have to do it. |
48 *error = base::StringPrintf("Catalog file is missing for locale %s.", | 48 *error = base::StringPrintf("Catalog file is missing for locale %s.", |
49 locale.c_str()); | 49 locale.c_str()); |
50 } else { | 50 } else { |
51 *error = extensions::ErrorUtils::FormatErrorMessage( | 51 *error = extensions::ErrorUtils::FormatErrorMessage( |
52 errors::kLocalesInvalidLocale, | 52 errors::kLocalesInvalidLocale, |
53 UTF16ToUTF8(file.LossyDisplayName()), | 53 base::UTF16ToUTF8(file.LossyDisplayName()), |
54 *error); | 54 *error); |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 return static_cast<base::DictionaryValue*>(dictionary); | 58 return static_cast<base::DictionaryValue*>(dictionary); |
59 } | 59 } |
60 | 60 |
61 // Localizes manifest value of string type for a given key. | 61 // Localizes manifest value of string type for a given key. |
62 bool LocalizeManifestValue(const std::string& key, | 62 bool LocalizeManifestValue(const std::string& key, |
63 const extensions::MessageBundle& messages, | 63 const extensions::MessageBundle& messages, |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 ScopedLocaleForTest::ScopedLocaleForTest(const std::string& locale) | 463 ScopedLocaleForTest::ScopedLocaleForTest(const std::string& locale) |
464 : locale_(extension_l10n_util::CurrentLocaleOrDefault()) { | 464 : locale_(extension_l10n_util::CurrentLocaleOrDefault()) { |
465 extension_l10n_util::SetProcessLocale(locale); | 465 extension_l10n_util::SetProcessLocale(locale); |
466 } | 466 } |
467 | 467 |
468 ScopedLocaleForTest::~ScopedLocaleForTest() { | 468 ScopedLocaleForTest::~ScopedLocaleForTest() { |
469 extension_l10n_util::SetProcessLocale(locale_); | 469 extension_l10n_util::SetProcessLocale(locale_); |
470 } | 470 } |
471 | 471 |
472 } // namespace extension_l10n_util | 472 } // namespace extension_l10n_util |
OLD | NEW |