| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 // Returns normalized current locale, or default locale - en_US. | 66 // Returns normalized current locale, or default locale - en_US. |
| 67 std::string CurrentLocaleOrDefault(); | 67 std::string CurrentLocaleOrDefault(); |
| 68 | 68 |
| 69 // Produce a vector of parent locales for given locale. | 69 // Produce a vector of parent locales for given locale. |
| 70 // It includes the current locale in the result. | 70 // It includes the current locale in the result. |
| 71 // sr_Cyrl_RS generates sr_Cyrl_RS, sr_Cyrl and sr. | 71 // sr_Cyrl_RS generates sr_Cyrl_RS, sr_Cyrl and sr. |
| 72 void GetParentLocales(const std::string& current_locale, | 72 void GetParentLocales(const std::string& current_locale, |
| 73 std::vector<std::string>* parent_locales); | 73 std::vector<std::string>* parent_locales); |
| 74 | 74 |
| 75 // Extends list of Chrome locales to them and their parents, so we can do |
| 76 // proper fallback. |
| 77 void GetAllLocales(std::set<std::string>* all_locales); |
| 78 |
| 75 // Adds valid locales to the extension. | 79 // Adds valid locales to the extension. |
| 76 // 1. Do nothing if _locales directory is missing (not an error). | 80 // 1. Do nothing if _locales directory is missing (not an error). |
| 77 // 2. Get list of Chrome locales. | 81 // 2. Get list of Chrome locales. |
| 78 // 3. Enumerate all subdirectories of _locales directory. | 82 // 3. Enumerate all subdirectories of _locales directory. |
| 79 // 4. Intersect both lists, and add intersection to the extension. | 83 // 4. Intersect both lists, and add intersection to the extension. |
| 80 // Returns false if any of supplied locales don't match chrome list of locales. | 84 // Returns false if any of supplied locales don't match chrome list of locales. |
| 81 // Fills out error with offending locale name. | 85 // Fills out error with offending locale name. |
| 82 bool GetValidLocales(const FilePath& locale_path, | 86 bool GetValidLocales(const FilePath& locale_path, |
| 83 std::set<std::string>* locales, | 87 std::set<std::string>* locales, |
| 84 std::string* error); | 88 std::string* error); |
| 85 | 89 |
| 86 // Loads messages file for default locale, and application locales (application | 90 // Loads messages file for default locale, and application locales (application |
| 87 // locales doesn't have to exist). Application locale is current locale and its | 91 // locales doesn't have to exist). Application locale is current locale and its |
| 88 // parents. | 92 // parents. |
| 89 // Returns message bundle if it can load default locale messages file, and all | 93 // Returns message bundle if it can load default locale messages file, and all |
| 90 // messages are valid, else returns NULL and sets error. | 94 // messages are valid, else returns NULL and sets error. |
| 91 ExtensionMessageBundle* LoadMessageCatalogs( | 95 ExtensionMessageBundle* LoadMessageCatalogs( |
| 92 const FilePath& locale_path, | 96 const FilePath& locale_path, |
| 93 const std::string& default_locale, | 97 const std::string& default_locale, |
| 94 const std::string& app_locale, | 98 const std::string& app_locale, |
| 95 const std::set<std::string>& valid_locales, | 99 const std::set<std::string>& valid_locales, |
| 96 std::string* error); | 100 std::string* error); |
| 97 | 101 |
| 102 // Returns bool if directory has "." in the name (for .svn) or if it doesn't |
| 103 // belong to Chrome locales. |
| 104 // |locales_path| is extension_id/_locales |
| 105 // |locale_path| is extension_id/_locales/xx |
| 106 // |all_locales| is a set of all valid Chrome locales. |
| 107 bool ShouldSkipValidation(const FilePath& locales_path, |
| 108 const FilePath& locale_path, |
| 109 const std::set<std::string>& all_locales); |
| 110 |
| 98 } // namespace extension_l10n_util | 111 } // namespace extension_l10n_util |
| 99 | 112 |
| 100 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ | 113 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ |
| OLD | NEW |