chromium 语言栏

因为语言栏的,我们只打算保留中英日

所以对于参数--lang

我们也需要做处理

找到处理的位置

对其进行处理

C:\ff\chromium\src\base\i18n\rtl.cc

void SetICUDefaultLocale(const std::string& locale_string) {
#if defined(OS_IOS)
  static base::debug::CrashKeyString* crash_key_locale =
      base::debug::AllocateCrashKeyString("icu_locale_input",
                                          base::debug::CrashKeySize::Size256);
  base::debug::SetCrashKeyString(crash_key_locale, locale_string);
#endif
  icu::Locale locale(ICULocaleName(locale_string).c_str());
  UErrorCode error_code = U_ZERO_ERROR;
  const char* lang = locale.getLanguage();
  if (lang != nullptr && *lang != '\0' && CheckLang(lang)) {
    icu::Locale::setDefault(locale, error_code);
  } else {
    LOG(ERROR) << "Failed to set the ICU default locale to " << locale_string
               << ". Falling back to en-US.";
    icu::Locale::setDefault(icu::Locale::getUS(), error_code);
  }
  g_icu_text_direction = UNKNOWN_DIRECTION;
}

bool CheckLang(const char* lang){
  if (!std::strcmp("ja",lang))
      return true;
  if (!std::strcmp("zh", lang))
      return true;
  if (!std::strcmp("en", lang))
    return true; 
  return false;
}

 

c:\ff\chromium\src\base\i18n\rtl.h

BASE_I18N_EXPORT bool CheckLang(const char* lang);

 

但是一直会出现

"Only clang-cl is supported on Windows, see https://crbug.com/988071"  

这是因为对VC++编译器的支持已经被删除,在这种情况下,在构建Chromium时,需要按照这个步骤

gn args out\Default

在该文件中指定is_clang布尔值true并保存:

is_clang=true

然后!

 

比如参数指定JA

 

又或者指定其他的比如nl什么的,会默认成en-US

完事了,对于参数

但是.......添加语言栏那边

本打算处理中间位置

也完事了

发现,处理这个东西,还是得源头处理

一顿找

找到一个敏感词

kAcceptLanguageList

有戏,一顿注释.........

所以前面都是为了啥

posted @ 2021-06-01 15:21  冰糖葫芦很乖  阅读(254)  评论(0编辑  收藏  举报