Skip to content
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

made sure that the i18n does use navigator.languages instead of navigator.language for automatic language detection #4244

Merged

Conversation

CommanderStorm
Copy link
Collaborator

@CommanderStorm CommanderStorm commented Dec 15, 2023

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

Fixes #4243

=> going through the locale list for matching locales fixes uk (but uk-UA) not being in our locales
image

I have tried to keep the merge conflict betwen this and #3893 to a minimum

Type of change

Please delete any options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas (including JSDoc for methods)
  • My changes generates no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

Please do not use any external image service. Instead, just paste in or drag and drop the image here, and it will be uploaded automatically.

@CommanderStorm CommanderStorm added bug Something isn't working area:core issues describing changes to the core of uptime kuma labels Dec 15, 2023
@CommanderStorm CommanderStorm changed the base branch from master to 1.23.X December 15, 2023 14:53
@CommanderStorm CommanderStorm changed the title made sure that the i18n does use navigator.languages made sure that the i18n does use navigator.languages instead of navigator.language for automatic language detection Dec 15, 2023
@louislam louislam modified the milestones: 2.0.0, 1.23.11 Dec 15, 2023
@chakflying chakflying modified the milestones: 1.23.11, 1.23.12 Jan 6, 2024
@louislam louislam merged commit 7635ab5 into louislam:1.23.X Jan 7, 2024
14 checks passed
@CommanderStorm CommanderStorm deleted the bug/locale-not-using-languages branch January 7, 2024 19:22
*/
export function currentLocale() {
const potentialLocales = [ localStorage.locale, navigator.language, navigator.language.substring(0, 2), ...navigator.languages ];
const availableLocales = potentialLocales.filter(l => languageList[l]);
Copy link

@CirnoT CirnoT Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always skip English because en (or its variants like en-US) is not present in languageList. Users with browser configured to send multiple supported locales will always have interface rendered in first non-English language.

Copy link

@CirnoT CirnoT Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also important to note that en is not guaranteed to be present in navigator.languages and instead one or more of its variants (en-US, en-GB) will be present as only choice. This should be accounted for!

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core issues describing changes to the core of uptime kuma bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use navigator.languages instead of navigator.language for language detection
4 participants