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

Use navigator.languages instead of navigator.language for language detection #4243

Closed
2 tasks done
cyberbellum96 opened this issue Dec 15, 2023 · 12 comments · Fixed by #4244
Closed
2 tasks done

Use navigator.languages instead of navigator.language for language detection #4243

cyberbellum96 opened this issue Dec 15, 2023 · 12 comments · Fixed by #4244
Labels
area:core issues describing changes to the core of uptime kuma bug Something isn't working good first issue Good for newcomers

Comments

@cyberbellum96
Copy link

cyberbellum96 commented Dec 15, 2023

⚠️ Please verify that this bug has NOT been raised before.

  • I checked and didn't find similar issue

🛡️ Security Policy

📝 Describe your problem (edited by @chaflying)

Language key uk is not recognized by the front-end, and the displayed language defaults back to en.

📝 Error Message(s) or Log

No response

🐻 Uptime-Kuma Version

1.23.10

💻 Operating System and Arch

Ubuntu 22.04.3 LTS

🌐 Browser

N/A

🐋 Docker Version

24.0.7

🟩 NodeJS Version

N/A

@CommanderStorm CommanderStorm added area:deployment related to how uptime kuma can be deployed area:core issues describing changes to the core of uptime kuma labels Dec 15, 2023
@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Dec 15, 2023

What do you mean by "for editing"? you have found the correct folder for editing the database

@CommanderStorm CommanderStorm added the question Further information is requested label Dec 15, 2023
@cyberbellum96
Copy link
Author

What do you mean by "for editing"? you have found the correct folder for editing the database

I need to change some status page data, but I can't find its source code. I already asked a question about changing the language on the status page. Now I need to find a file where I can edit the default language for site visitors.

@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Dec 15, 2023

First of all, it seems like you are using docker.
Note that modifications to this part would be temporary and revert at the next reboot.

A default language and locale switcher is included in #3523 and said PR will be reviewed in the v2.1 release train.

See #1643
=> there is no "default language" for site visitors, this is dependent on which language the OS is set to.

Localising the footer/.. is tracked here: #2784

Our contibution guide (including how to get a dev environment set up) is here: https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md

@cyberbellum96
Copy link
Author

First of all, it seems like you are using docker. Note that modifications to this part would be temporary and revert at the next reboot.

A default language and locale switcher is included in #3523 and said PR will be reviewed in the v2.1 release train.

See #1643 => there is no "default language" for site visitors, this is dependent on which language the OS is set to.

Localising the footer/.. is tracked here: #2784

Our contibution guide (including how to get a dev environment set up) is here: https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md

I have "Ukrainian" in my OS settings, but by default it displays in English.

@CommanderStorm
Copy link
Collaborator

The default language is determined like this:

uptime-kuma/src/i18n.js

Lines 60 to 63 in 8151ac0

export const currentLocale = () => localStorage.locale
|| languageList[navigator.language] && navigator.language
|| languageList[navigator.language.substring(0, 2)] && navigator.language.substring(0, 2)
|| "en";

Could you run the following commands in the console with uptime open?

localStorage.locale
navigator.language

@cyberbellum96
Copy link
Author

cyberbellum96 commented Dec 15, 2023

The default language is determined like this:

uptime-kuma/src/i18n.js

Lines 60 to 63 in 8151ac0

export const currentLocale = () => localStorage.locale
|| languageList[navigator.language] && navigator.language
|| languageList[navigator.language.substring(0, 2)] && navigator.language.substring(0, 2)
|| "en";

The problem is that I can't find where this file is located: uptime-kuma/src/i18n.js

Could you run the following commands in the console with uptime open?

localStorage.locale
navigator.language

How exactly should I execute these commands through the console?

@cyberbellum96
Copy link
Author

cyberbellum96 commented Dec 15, 2023

I managed to find 3 i18n.js files at the following address: var/lib/docker/overlay2/[many numbers and letters]/diff/app/src

@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Dec 15, 2023

How exactly should I execute these commands through the console?

The console is integrated into your browser (assuming you use chrome given that you did not fill out that field). Open the the inspector via right-clicking

image

and then

image

@cyberbellum96
Copy link
Author

cyberbellum96 commented Dec 15, 2023

Desktop 15-12-2023 16-09-28-646
It should be in Ukrainian, but it is displayed in English.
Desktop 15-12-2023 16-09-37-945

@CommanderStorm CommanderStorm changed the title Where can I find the location of the uptime-kuma folder for editing? Use navigator.languages instead of navigator.language for language detection Dec 15, 2023
@CommanderStorm CommanderStorm added bug Something isn't working and removed help labels Dec 15, 2023
@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Dec 15, 2023

The reason for this is that we currently only support the uk-UA locale and not uk

I think a better approach compared to the current one would be to use the following instead:
image

Docs: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages

@cyberbellum96
Copy link
Author

cyberbellum96 commented Dec 15, 2023

Okay, I understand what the problem is. Thank you very much!

@CommanderStorm CommanderStorm added good first issue Good for newcomers and removed question Further information is requested area:deployment related to how uptime kuma can be deployed labels Dec 15, 2023
@CommanderStorm
Copy link
Collaborator

Closing as #4244 was merged

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 good first issue Good for newcomers
Projects
None yet
2 participants