diff options
author | cira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-18 21:07:39 +0000 |
---|---|---|
committer | cira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-18 21:07:39 +0000 |
commit | 42b6f0f83579563a94bd9fdeec83574a1a932f18 (patch) | |
tree | bfdb770830f27f306eaeca8da46a6dd9e7ed8647 /chrome/browser/extensions/extension_l10n_util.h | |
parent | 60ad3e2b8540ba00a2e5d0624fd2796e7780b11c (diff) | |
download | chromium_src-42b6f0f83579563a94bd9fdeec83574a1a932f18.zip chromium_src-42b6f0f83579563a94bd9fdeec83574a1a932f18.tar.gz chromium_src-42b6f0f83579563a94bd9fdeec83574a1a932f18.tar.bz2 |
CL is the same as http://codereview.chromium.org/173487, but had to be moved to new CL number because I switched machines.
Implemented the rest of loading/parsing logic for extension i18n:
1. Loading message catalogs for default and application locale.
2. Parsing JSON and replacing placeholders with actual content within a message.
3. Creating unified dictionary (union of default and application dictionaries,
where application dict. has priority for common messages).
New class ExtensionMessageBundle holds new dictionary, and parses data. It's
injected into Extension.
ExtensionMessageHandler::ReplaceVariablesInString can replace both
$placeholders$ and __MSG_messages__ in given string (HTML, manifest, actual
message string...).
Implemented actual manifest name/description replacement too, as an example.
Extension is now pretty agnostic about localization, and this makes it easier to use message bundles
with things that are not extensions...
BUG=12131
Review URL: http://codereview.chromium.org/202063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26609 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_l10n_util.h')
-rw-r--r-- | chrome/browser/extensions/extension_l10n_util.h | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/chrome/browser/extensions/extension_l10n_util.h b/chrome/browser/extensions/extension_l10n_util.h index be73f99..98759ab 100644 --- a/chrome/browser/extensions/extension_l10n_util.h +++ b/chrome/browser/extensions/extension_l10n_util.h @@ -12,13 +12,15 @@ class DictionaryValue; class Extension; +class ExtensionMessageBundle; class FilePath; namespace extension_l10n_util { -// Returns true if default_locale was set to valid locale -// (supported by the extension). -bool ValidateDefaultLocale(const Extension* extension); +// Returns default locale in form "en-US" or "sr" or empty string if +// "default_locale" section was not defined in the manifest.json file. +std::string GetDefaultLocaleFromManifest(const DictionaryValue& manifest, + std::string* error); // Adds locale_name to the extension if it's in chrome_locales, and // if messages file is present (we don't check content of messages file here). @@ -27,7 +29,7 @@ bool ValidateDefaultLocale(const Extension* extension); // If file name starts with . return true (helps testing extensions under svn). bool AddLocale(const std::set<std::string>& chrome_locales, const FilePath& locale_folder, - Extension* extension, + std::set<std::string>* valid_locales, std::string* locale_name, std::string* error); @@ -38,10 +40,21 @@ bool AddLocale(const std::set<std::string>& chrome_locales, // 4. Intersect both lists, and add intersection to the extension. // Returns false if any of supplied locales don't match chrome list of locales. // Fills out error with offending locale name. -bool AddValidLocales(const FilePath& locale_path, - Extension* extension, +bool GetValidLocales(const FilePath& locale_path, + std::set<std::string>* locales, std::string* error); +// Loads messages file for default locale, and application locale (application +// locale doesn't have to exist). +// It creates simplified in-memory representation of name-value pairs, where +// value part is actual message with placeholders resolved. +// Returns message bundle if it can load default locale messages file, and all +// messages are valid, else returns NULL and sets error. +ExtensionMessageBundle* LoadMessageCatalogs(const FilePath& locale_path, + const std::string& default_locale, + const std::string& app_locale, + std::string* error); + } // namespace extension_l10n_util #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_L10N_UTIL_H_ |