#include "extensions/common/extension_l10n_util.h"
#include <stddef.h>
#include <set>
#include <string>
#include <string_view>
#include <vector>
#include "base/containers/contains.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/json/json_file_value_serializer.h"
#include "base/json/json_string_value_serializer.h"
#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "extensions/common/constants.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension.h"
#include "extensions/common/extensions_client.h"
#include "extensions/common/file_util.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/message_bundle.h"
#include "extensions/common/utils/base_string.h"
#include "third_party/icu/source/common/unicode/uloc.h"
#include "third_party/zlib/google/compression_utils.h"
#include "ui/base/l10n/l10n_util.h"
errors;
keys;
namespace {
bool g_allow_gzipped_messages_for_test = …;
std::unique_ptr<base::Value::Dict> LoadMessageFile(
const base::FilePath& locale_path,
const std::string& locale,
std::string* error,
extension_l10n_util::GzippedMessagesPermission gzip_permission) { … }
bool LocalizeManifestValue(const std::string& key,
const extensions::MessageBundle& messages,
base::Value::Dict* manifest,
std::string* error) { … }
bool LocalizeManifestListValue(const std::string& key,
const extensions::MessageBundle& messages,
base::Value::Dict* manifest,
std::string* error) { … }
std::string& GetProcessLocale() { … }
std::string& GetPreferredLocale() { … }
std::string LocaleForLocalization() { … }
}
namespace extension_l10n_util {
GzippedMessagesPermission GetGzippedMessagesPermissionForExtension(
const extensions::Extension* extension) { … }
GzippedMessagesPermission GetGzippedMessagesPermissionForLocation(
extensions::mojom::ManifestLocation location) { … }
base::AutoReset<bool> AllowGzippedMessagesAllowedForTest() { … }
void SetProcessLocale(const std::string& locale) { … }
void SetPreferredLocale(const std::string& locale) { … }
std::string GetDefaultLocaleFromManifest(const base::Value::Dict& manifest,
std::string* error) { … }
bool ShouldRelocalizeManifest(const base::Value::Dict& manifest) { … }
bool LocalizeManifest(const extensions::MessageBundle& messages,
base::Value::Dict* manifest,
std::string* error) { … }
bool LocalizeExtension(const base::FilePath& extension_path,
base::Value::Dict* manifest,
GzippedMessagesPermission gzip_permission,
std::string* error) { … }
bool AddLocale(const std::set<std::string>& chrome_locales,
const base::FilePath& locale_folder,
const std::string& locale_name,
std::set<std::string>* valid_locales,
std::string* error) { … }
std::string CurrentLocaleOrDefault() { … }
void GetAllLocales(std::set<std::string>* all_locales) { … }
void GetAllFallbackLocales(const std::string& default_locale,
std::vector<std::string>* all_fallback_locales) { … }
bool GetValidLocales(const base::FilePath& locale_path,
std::set<std::string>* valid_locales,
std::string* error) { … }
extensions::MessageBundle* LoadMessageCatalogs(
const base::FilePath& locale_path,
const std::string& default_locale,
GzippedMessagesPermission gzip_permission,
std::string* error) { … }
bool ValidateExtensionLocales(const base::FilePath& extension_path,
const base::Value::Dict& manifest,
std::string* error) { … }
bool ShouldSkipValidation(const base::FilePath& locales_path,
const base::FilePath& locale_path,
const std::set<std::string>& all_locales) { … }
ScopedLocaleForTest::ScopedLocaleForTest()
: … { … }
ScopedLocaleForTest::ScopedLocaleForTest(std::string_view locale)
: … { … }
ScopedLocaleForTest::ScopedLocaleForTest(std::string_view process_locale,
std::string_view preferred_locale)
: … { … }
ScopedLocaleForTest::~ScopedLocaleForTest() { … }
const std::string& GetPreferredLocaleForTest() { … }
}