| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 9 #pragma once |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // if messages file is present (we don't check content of messages file here). | 52 // if messages file is present (we don't check content of messages file here). |
| 53 // Returns false if locale_name was not found in chrome_locales, and sets | 53 // Returns false if locale_name was not found in chrome_locales, and sets |
| 54 // error with locale_name. | 54 // error with locale_name. |
| 55 // If file name starts with . return true (helps testing extensions under svn). | 55 // If file name starts with . return true (helps testing extensions under svn). |
| 56 bool AddLocale(const std::set<std::string>& chrome_locales, | 56 bool AddLocale(const std::set<std::string>& chrome_locales, |
| 57 const FilePath& locale_folder, | 57 const FilePath& locale_folder, |
| 58 const std::string& locale_name, | 58 const std::string& locale_name, |
| 59 std::set<std::string>* valid_locales, | 59 std::set<std::string>* valid_locales, |
| 60 std::string* error); | 60 std::string* error); |
| 61 | 61 |
| 62 // Converts all - into _, to be consistent with ICU and file system names. | |
| 63 std::string NormalizeLocale(const std::string& locale); | |
| 64 | |
| 65 // Returns normalized current locale, or default locale - en_US. | 62 // Returns normalized current locale, or default locale - en_US. |
| 66 std::string CurrentLocaleOrDefault(); | 63 std::string CurrentLocaleOrDefault(); |
| 67 | 64 |
| 68 // Produce a vector of parent locales for given locale. | |
| 69 // It includes the current locale in the result. | |
| 70 // sr_Cyrl_RS generates sr_Cyrl_RS, sr_Cyrl and sr. | |
| 71 void GetParentLocales(const std::string& current_locale, | |
| 72 std::vector<std::string>* parent_locales); | |
| 73 | |
| 74 // Extends list of Chrome locales to them and their parents, so we can do | 65 // Extends list of Chrome locales to them and their parents, so we can do |
| 75 // proper fallback. | 66 // proper fallback. |
| 76 void GetAllLocales(std::set<std::string>* all_locales); | 67 void GetAllLocales(std::set<std::string>* all_locales); |
| 77 | 68 |
| 78 // Adds valid locales to the extension. | 69 // Adds valid locales to the extension. |
| 79 // 1. Do nothing if _locales directory is missing (not an error). | 70 // 1. Do nothing if _locales directory is missing (not an error). |
| 80 // 2. Get list of Chrome locales. | 71 // 2. Get list of Chrome locales. |
| 81 // 3. Enumerate all subdirectories of _locales directory. | 72 // 3. Enumerate all subdirectories of _locales directory. |
| 82 // 4. Intersect both lists, and add intersection to the extension. | 73 // 4. Intersect both lists, and add intersection to the extension. |
| 83 // Returns false if any of supplied locales don't match chrome list of locales. | 74 // Returns false if any of supplied locales don't match chrome list of locales. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 103 // |locales_path| is extension_id/_locales | 94 // |locales_path| is extension_id/_locales |
| 104 // |locale_path| is extension_id/_locales/xx | 95 // |locale_path| is extension_id/_locales/xx |
| 105 // |all_locales| is a set of all valid Chrome locales. | 96 // |all_locales| is a set of all valid Chrome locales. |
| 106 bool ShouldSkipValidation(const FilePath& locales_path, | 97 bool ShouldSkipValidation(const FilePath& locales_path, |
| 107 const FilePath& locale_path, | 98 const FilePath& locale_path, |
| 108 const std::set<std::string>& all_locales); | 99 const std::set<std::string>& all_locales); |
| 109 | 100 |
| 110 } // namespace extension_l10n_util | 101 } // namespace extension_l10n_util |
| 111 | 102 |
| 112 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ | 103 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ |
| OLD | NEW |