Chromium Code Reviews

Side by Side Diff: chrome/common/extensions/extension_l10n_util.h

Issue 5643002: Add utility function to determine if a locale is valid syntax; this will... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
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 68 matching lines...)
79 // 1. Do nothing if _locales directory is missing (not an error). 79 // 1. Do nothing if _locales directory is missing (not an error).
80 // 2. Get list of Chrome locales. 80 // 2. Get list of Chrome locales.
81 // 3. Enumerate all subdirectories of _locales directory. 81 // 3. Enumerate all subdirectories of _locales directory.
82 // 4. Intersect both lists, and add intersection to the extension. 82 // 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. 83 // Returns false if any of supplied locales don't match chrome list of locales.
84 // Fills out error with offending locale name. 84 // Fills out error with offending locale name.
85 bool GetValidLocales(const FilePath& locale_path, 85 bool GetValidLocales(const FilePath& locale_path,
86 std::set<std::string>* locales, 86 std::set<std::string>* locales,
87 std::string* error); 87 std::string* error);
88 88
89 // Checks if a string is plausibly a syntactically-valid locale string,
90 // for cases where we want the valid input to be a locale string such as
91 // 'en', 'pt-BR', 'fil', and 'zh-Hans-CN', but we don't want to limit it
92 // to locales that Chrome actually knows about, so 'xx-YY' should be
93 // accepted, but 'z', 'German', 'en-$1', or 'abcd-1234' should not.
94 // Case-insensitive. Based on RFC 5646.
95 bool IsValidLocaleSyntax(const std::string& locale);
96
89 // Loads messages file for default locale, and application locales (application 97 // Loads messages file for default locale, and application locales (application
90 // locales doesn't have to exist). Application locale is current locale and its 98 // locales doesn't have to exist). Application locale is current locale and its
91 // parents. 99 // parents.
92 // Returns message bundle if it can load default locale messages file, and all 100 // Returns message bundle if it can load default locale messages file, and all
93 // messages are valid, else returns NULL and sets error. 101 // messages are valid, else returns NULL and sets error.
94 ExtensionMessageBundle* LoadMessageCatalogs( 102 ExtensionMessageBundle* LoadMessageCatalogs(
95 const FilePath& locale_path, 103 const FilePath& locale_path,
96 const std::string& default_locale, 104 const std::string& default_locale,
97 const std::string& app_locale, 105 const std::string& app_locale,
98 const std::set<std::string>& valid_locales, 106 const std::set<std::string>& valid_locales,
99 std::string* error); 107 std::string* error);
100 108
101 // Returns true if directory has "." in the name (for .svn) or if it doesn't 109 // Returns true if directory has "." in the name (for .svn) or if it doesn't
102 // belong to Chrome locales. 110 // belong to Chrome locales.
103 // |locales_path| is extension_id/_locales 111 // |locales_path| is extension_id/_locales
104 // |locale_path| is extension_id/_locales/xx 112 // |locale_path| is extension_id/_locales/xx
105 // |all_locales| is a set of all valid Chrome locales. 113 // |all_locales| is a set of all valid Chrome locales.
106 bool ShouldSkipValidation(const FilePath& locales_path, 114 bool ShouldSkipValidation(const FilePath& locales_path,
107 const FilePath& locale_path, 115 const FilePath& locale_path,
108 const std::set<std::string>& all_locales); 116 const std::set<std::string>& all_locales);
109 117
110 } // namespace extension_l10n_util 118 } // namespace extension_l10n_util
111 119
112 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ 120 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/extension_l10n_util.cc » ('j') | chrome/common/extensions/extension_l10n_util.cc » ('J')

Powered by Google App Engine