kimai / www.kimai.org

Website for the Kimai time-tracker
https://www.kimai.org
GNU Affero General Public License v3.0
18 stars 88 forks source link

Automatic language detection for the website #356

Open milotype opened 6 months ago

milotype commented 6 months ago

Feature request: Implement automatic language detection for the website Kimai - Open Source time-tracker according to the language setting of the user's browser or the user's system language setting.

If you don't want that, I'd suggest to place the language dropdown menu into the navigation bar at the top of the webpage instead of at the footer of the webpage.

kevinpapst commented 6 months ago

Implementation idea:

Could use

var lang = navigator.language || navigator.userLanguage;

and then compare with <html lang="en">.

For example if de is detected, check if there is a <link rel="alternate" hreflang="de" href="https://www.kimai.org/de/"> and redirect there.

If not existing, check if one of the users fallback languages is existing and redirect.

If redirect happens, set a session cookie. If a language is chosen manually in the dropdown, set the session cookie as well.

ONLY execute the above logic on https://www.kimai.org Do NOT redirect if cookie is existing, to prevent redirect-loops.