Repository navigation
Add German translation and browser language detection - #55
Merged
Merged
Conversation
Owner
|
Thanks for the German translation 🙌 Right now the language comes only from the browser's Accept-Language, so users can't change it by hand. Could you add a language setting to the Settings dialog?
Thanks! |
German for the Insights settings and notice, the song panel field settings and the hidden custom tags hint.
A Language section (listener and up) offers Automatic, English and Deutsch, built from the locales in src/i18n/locale.ts. The choice is stored under the 'locale' config key; request.ts uses it when it names a supported locale and otherwise negotiates from Accept-Language as before. Saving refreshes the router so the server renders the new language.
Contributor
Author
|
Done, thanks for the detailed pointers!
Checked:
|
Owner
|
There you go https://github.com/suitux/Tagr/releases/tag/v1.14.0 😄 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a German translation (
messages/de.json) and lets Tagr choose the UI language from the browser'sAccept-Languageheader instead of the hard-codeden.How
src/i18n/locale.ts(new) — the list of supported locales (en,de), the default (en) andnegotiateLocale(), which walks theAccept-Languageentries by quality value, matches regional tags to their base language (de-AT→de) and falls back to English for anything unsupported or malformed.src/i18n/request.ts— usesnegotiateLocale((await headers()).get('accept-language'))instead ofconst locale = 'en'.src/app/layout.tsx—<html lang>now reflects the active locale (getLocale()), so the layout isasync. No other change in that file.messages/de.json(new) — all 420 keys ofen.json, same structure, same placeholders and plural branches, ICU syntax unchanged.src/i18n/locale.test.ts(new) — tests for the negotiation, plus a check that every non-English message file has exactly the keys and placeholders ofen.json, so a future key added only toen.jsonshows up in CI.README.md— one bullet under Additional describing the language selection and how to add a language.Browsers asking for any other language keep getting English, so nothing changes for existing users.
Testing
vitest run: all test files pass, including the 6 new tests.eslintandprettier --checkpass on the new and changed files. (src/app/layout.tsxwas already not Prettier-formatted onmain; I only changed the lines above and left the rest untouched to keep the diff small.)tsc --noEmitreports the same two errors indetail-panel-preview-card.tsxonmainand on this branch — none are introduced here.Accept-Language: enorfreverything stays English.Not included
Dates in the song list are still formatted with a fixed
'en-US'insrc/components/panels/main-content/utils.ts. That could follow the active locale too, but I kept this PR to the translation itself.The translation was prepared with the help of an AI assistant (Claude) and reviewed by me as a native German speaker.