-
Notifications
You must be signed in to change notification settings - Fork 15.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add app.getPreferredSystemLanguages() API #36035
Conversation
macOS Monterey screenshotsA screenshot showing that the strings returned by Canadian French (fr-CA) is the preferred language, whereas Finland (FI) is the region, and Swiss German (de-CH) is the language passed in through the I didn't expect |
Sample results on Windows 11
|
Yes this is expected, it depends on what Cocoa locale the application supports. It is the list of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linux implementation can return the list from g_get_language_names instead of empty result. NOTE: l10n_util::GetApplicationLocaleInternal also uses it but we cannot call into this base API because it eventually returns the locale for which translatable strings are available in the application.
I wasn't able to add tables as examples due to the error message
I have added nested lists for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting close! Implementation LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
We need a few more API LGTMs from @electron/wg-api. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(sorry x3)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x4
x5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x10
Release Notes Persisted
|
* feat: add app.getSystemLanguage() API * Change the API to getPreferredSystemLanguages * Fix test * Clarify docs and add Linux impl * Remove USE_GLIB * Don't add C to list * Remove examples since there's a lot of edge cases * Fix lint * Add examples * Fix compile error * Apply PR feedback * Update the example Co-authored-by: Raymond Zhao <7199958+rzhao271@users.noreply.github.com>
I have automatically backported this PR to "21-x-y", please check out #36290 |
I have automatically backported this PR to "22-x-y", please check out #36291 |
feat: add app.getPreferredSystemLanguages() API (#36035) * feat: add app.getSystemLanguage() API * Change the API to getPreferredSystemLanguages * Fix test * Clarify docs and add Linux impl * Remove USE_GLIB * Don't add C to list * Remove examples since there's a lot of edge cases * Fix lint * Add examples * Fix compile error * Apply PR feedback * Update the example Co-authored-by: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Raymond Zhao <7199958+rzhao271@users.noreply.github.com>
* feat: add app.getSystemLanguage() API * Change the API to getPreferredSystemLanguages * Fix test * Clarify docs and add Linux impl * Remove USE_GLIB * Don't add C to list * Remove examples since there's a lot of edge cases * Fix lint * Add examples * Fix compile error * Apply PR feedback * Update the example
Description of Change
This PR provides an API that retrieves the user's preferred system languages.
It turns out that retrieving the user's locale often ends up retrieving "actual locale" data, which isn't what I originally wanted with PR #35697. However, upon discussing with @deepak1556, returning the "actual locale" data makes sense for a method named
app.getSystemLocale
, so this PR adds a new method,app.getPreferredSytemLanguages
, that returnsGetPreferredLanguages()
.Downstream: microsoft/vscode#159958.
Checklist
npm test
passesRelease Notes
Notes: Added an
app.getPreferredSystemLanguages()
API to return the user's system languages.