-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Move OS utility to language_util
- Loading branch information
Showing
9 changed files
with
97 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2020 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef SHELL_COMMON_LANGUAGE_UTIL_H_ | ||
#define SHELL_COMMON_LANGUAGE_UTIL_H_ | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "base/strings/string16.h" | ||
|
||
namespace electron { | ||
|
||
// Return a list of user preferred languages from OS. The list doesn't include | ||
// overrides from command line arguments. | ||
std::vector<std::string> GetPreferredLanguages(); | ||
|
||
#if defined(OS_WIN) | ||
bool GetPreferredLanguagesUsingGlobalization( | ||
std::vector<base::string16>* languages); | ||
#endif | ||
|
||
} // namespace electron | ||
|
||
#endif // SHELL_COMMON_LANGUAGE_UTIL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// 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" | ||
|
||
#include "ui/base/l10n/l10n_util.h" | ||
|
||
namespace electron { | ||
|
||
std::vector<std::string> GetPreferredLanguages() { | ||
std::vector<std::string> languages = {l10n_util::GetApplicationLocale("")}; | ||
return languages; | ||
} | ||
|
||
} // namespace electron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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 "base/strings/sys_string_conversions.h" | ||
|
||
namespace electron { | ||
|
||
std::vector<std::string> GetPreferredLanguages() { | ||
std::vector<std::string> languages; | ||
[[NSLocale preferredLanguages] | ||
enumerateObjectsUsingBlock:^(NSString* language, NSUInteger i, | ||
BOOL* stop) { | ||
languages.push_back(base::SysNSStringToUTF8(language)); | ||
}]; | ||
return languages; | ||
} | ||
|
||
} // namespace electron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters