fix: respect system language preferences on Win/macOS (#23247)
This commit fixes https://github.com/electron/electron/issues/18829 Previously the full preferences set to OS was not given to Chromium. Also, this commit improves fallback font selection for CJK text. Chromium uses browser languages to determine fallback fonts on Windows, especially kanji/han characters in CJK. For instance, when user sets 'en-US, ja-JP' to Accept-Language, while Chromium chooses Japanese font for kanji text, but Electron chooses Chinese font. This is because only the first language was given to Accept-Language on Electron. This patch is based on https://github.com/electron/electron/pull/15532 Co-authored-by: Nitish Sakhawalkar <nitsakh@icloud.com> Co-authored-by: Kasumi Hanazuki <kasumi@rollingapple.net> Co-authored-by: Nitish Sakhawalkar <nitsakh@icloud.com> Co-authored-by: Kasumi Hanazuki <kasumi@rollingapple.net>
This commit is contained in:
parent
45d1ebe961
commit
f176d2494f
7 changed files with 168 additions and 3 deletions
25
shell/common/language_util_mac.mm
Normal file
25
shell/common/language_util_mac.mm
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) 2020 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/common/language_util.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
std::vector<std::string> GetPreferredLanguages() {
|
||||
__block std::vector<std::string> languages;
|
||||
[[NSLocale preferredLanguages]
|
||||
enumerateObjectsUsingBlock:^(NSString* language, NSUInteger i,
|
||||
BOOL* stop) {
|
||||
languages.push_back(base::SysNSStringToUTF8(language));
|
||||
}];
|
||||
return languages;
|
||||
}
|
||||
|
||||
} // namespace electron
|
Loading…
Add table
Add a link
Reference in a new issue