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 // This file declares extension specific l10n utils. | 5 // This file declares extension specific l10n utils. |
6 | 6 |
7 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ | 7 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ |
8 #define CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ | 8 #define CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 std::set<std::string>* valid_locales, | 61 std::set<std::string>* valid_locales, |
62 std::string* error); | 62 std::string* error); |
63 | 63 |
64 // Returns normalized current locale, or default locale - en_US. | 64 // Returns normalized current locale, or default locale - en_US. |
65 std::string CurrentLocaleOrDefault(); | 65 std::string CurrentLocaleOrDefault(); |
66 | 66 |
67 // Extends list of Chrome locales to them and their parents, so we can do | 67 // Extends list of Chrome locales to them and their parents, so we can do |
68 // proper fallback. | 68 // proper fallback. |
69 void GetAllLocales(std::set<std::string>* all_locales); | 69 void GetAllLocales(std::set<std::string>* all_locales); |
70 | 70 |
| 71 // Provides a vector of all fallback locales for message localization. |
| 72 // The vector is ordered by priority of locale - |application_locale|, |
| 73 // first_parent, ..., |default_locale|. |
| 74 void GetAllFallbackLocales(const std::string& application_locale, |
| 75 const std::string& default_locale, |
| 76 std::vector<std::string>* all_fallback_locales); |
| 77 |
71 // Adds valid locales to the extension. | 78 // Adds valid locales to the extension. |
72 // 1. Do nothing if _locales directory is missing (not an error). | 79 // 1. Do nothing if _locales directory is missing (not an error). |
73 // 2. Get list of Chrome locales. | 80 // 2. Get list of Chrome locales. |
74 // 3. Enumerate all subdirectories of _locales directory. | 81 // 3. Enumerate all subdirectories of _locales directory. |
75 // 4. Intersect both lists, and add intersection to the extension. | 82 // 4. Intersect both lists, and add intersection to the extension. |
76 // Returns false if any of supplied locales don't match chrome list of locales. | 83 // Returns false if any of supplied locales don't match chrome list of locales. |
77 // Fills out error with offending locale name. | 84 // Fills out error with offending locale name. |
78 bool GetValidLocales(const FilePath& locale_path, | 85 bool GetValidLocales(const FilePath& locale_path, |
79 std::set<std::string>* locales, | 86 std::set<std::string>* locales, |
80 std::string* error); | 87 std::string* error); |
(...skipping 15 matching lines...) Expand all Loading... |
96 // |locales_path| is extension_id/_locales | 103 // |locales_path| is extension_id/_locales |
97 // |locale_path| is extension_id/_locales/xx | 104 // |locale_path| is extension_id/_locales/xx |
98 // |all_locales| is a set of all valid Chrome locales. | 105 // |all_locales| is a set of all valid Chrome locales. |
99 bool ShouldSkipValidation(const FilePath& locales_path, | 106 bool ShouldSkipValidation(const FilePath& locales_path, |
100 const FilePath& locale_path, | 107 const FilePath& locale_path, |
101 const std::set<std::string>& all_locales); | 108 const std::set<std::string>& all_locales); |
102 | 109 |
103 } // namespace extension_l10n_util | 110 } // namespace extension_l10n_util |
104 | 111 |
105 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ | 112 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ |
OLD | NEW |