chromium/extensions/common/extension_l10n_util.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 =;

// Loads contents of the messages file for given locale. If file is not found,
// or there was parsing error we return null and set |error|. If
// |gzip_permission| is kAllowForTrustedSource, this will also look for a .gz
// version of the file and if found will decompresses it into a string first.
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) {}

// Localizes manifest value of string type for a given key.
bool LocalizeManifestValue(const std::string& key,
                           const extensions::MessageBundle& messages,
                           base::Value::Dict* manifest,
                           std::string* error) {}

// Localizes manifest value of list type for a given key.
bool LocalizeManifestListValue(const std::string& key,
                               const extensions::MessageBundle& messages,
                               base::Value::Dict* manifest,
                               std::string* error) {}

std::string& GetProcessLocale() {}

std::string& GetPreferredLocale() {}

// Returns the desired locale to use for localization.
std::string LocaleForLocalization() {}

}  // namespace

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() {}

}  // namespace extension_l10n_util