louislam / uptime-kuma

A fancy self-hosted monitoring tool
https://uptime.kuma.pet
MIT License
59.78k stars 5.34k forks source link

Handle "ru" language on Safari #2843

Closed sanchesfree closed 9 months ago

sanchesfree commented 1 year ago

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

🛡️ Security Policy

Description

In safari the locale is defined as "ru", but in Chrome it is "ru-RU".

Because of this on the status pages in safari the inscriptions are in English.

If you rename file src/lang/ru-RU.json to src/lang/ru.json, this language will be connected in both Chrome and Safari. and change languageList key in /src/i18n.js from "ru-RU" to "ru"

👟 Reproduction steps

create status page. open page in safari

👀 Expected behavior

title from ru file "Все системы работают в штатном режиме"

😓 Actual Behavior

title from en file "All Systems Operational"

🐻 Uptime-Kuma Version

1.20.1

💻 Operating System and Arch

ubuntu

🌐 Browser

Safari 16.3

🐋 Docker Version

No response

🟩 NodeJS Version

No response

📝 Relevant log output

No response

rezzorix commented 1 year ago

I just looked a bit through the locale file names and there is indeed no clear naming convention followed here for this…

Some are in format “language_Territory” some are not.

With regards to language Wwe should follow one standard - ideally one that is most compatible…

Is this issue for the Russian language isolated to this one only or for others as well?

sanchesfree commented 1 year ago

I think it is enough to rename all locales to a two-letter format, because the first two letters denote the language and the rest is the dialect. It's not that important, most likely. For the Russian language, that's for sure. Does British English or American English make a difference in this Web application? I don't think so.

Here are examples of locales

https://help.sap.com/docs/SAP_BUSINESSOBJECTS_BUSINESS_INTELLIGENCE_PLATFORM/09382741061c40a989fae01e61d54202/46758c5e6e041014910aba7db0e91070.html?version=4.2.4&locale=en-US

louislam commented 1 year ago

Currently, it depends on a single variable navigator.language, so if changed it, I think Chrome will be not working anymore. https://github.com/louislam/uptime-kuma/blob/a80f2281367b3fe1f658288200d7a923346a92a1/src/i18n.js#L58

I think it should be handled in code like: if navigator.language == "ru", then current language = "ru-RU"

Or change to use navigator.languages (with s), but I still not sure whether it is in the list, you can check it on: https://jsfiddle.net/a6cbdq8u/

Some are in format “language_Territory” some are not.

I checked on Weblate, they do provide both formats, I think it is part of ISO standards.

I think it is enough to rename all locales to a two-letter format

Incorrect for zh-* and many other languages, they are pretty different.

sanchesfree commented 1 year ago

Why not rename lang file ru-RU to ru and change key in array to ru ?

Judging by this code, both ru and ru-RU will be processed in the end uptime-kuma/src/i18n.js

CommanderStorm commented 9 months ago

4244 was merged into the 1.23.12 bugfix release (and will thus be included in future releases)

=> closing as resolved by looking at navigator.languages instead of navigator.language