Skip to content

feat: add German language support (DE/EN/FR) - #17

Merged
Logarex merged 2 commits into
Logarex:mainfrom
mkocustos:feat/i18n-german
May 18, 2026
Merged

feat: add German language support (DE/EN/FR)#17
Logarex merged 2 commits into
Logarex:mainfrom
mkocustos:feat/i18n-german

Conversation

@mkocustos

@mkocustos mkocustos commented May 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds full German (de) translations for all namespaces: common, auth, recipes, editor, importRecipe, settings, privacy
  • Adds a german key to the existing English and French settings translations
  • Language auto-detected from device locale: German device → Deutsch, English device → English, everything else → Français (existing fallback unchanged)
  • Language remains manually overridable in Settings — a new third segment Deutsch appears alongside Français and English
  • Extends the language type from "fr" | "en" to "fr" | "en" | "de" in PreferencesProvider and persists the selection via AsyncStorage

Files changed

File Change
src/i18n/index.ts German translation block; german key added to EN + FR; updated language detection
src/features/preferences/PreferencesProvider.tsx Type extended to "fr" | "en" | "de"; init and validation logic updated
src/screens/SettingsScreen.tsx Third language option (Deutsch) added to SegmentedControl

Bug fix: auto-detection overridden by stale AsyncStorage value

Problem: On first launch after installing the update, the app could show the wrong language (e.g. English) even on a German device. The PreferencesProvider reads any previously stored language from AsyncStorage and applies it unconditionally — including values written by an older version of the app that had no German support. Since those older values were never explicitly chosen by the user (they were set automatically), the stored "en" would silently override the device locale.

Fix: A separate preferences.language.userSet flag is now written to AsyncStorage only when the user actively changes the language via setLanguage. On startup, the stored language is only restored if this flag is true. If no explicit choice has been recorded, the device locale is used as intended.

Testing

Tested on Apple iPhone with Expo Go — app correctly launches in German on a German-locale device. Language switching in Settings also works as expected.

This implementation was generated with Claude Code.

- Add full German translations for all namespaces (common, auth,
  recipes, editor, importRecipe, settings, privacy)
- Add `german` key to existing EN and FR settings translations
- Auto-detect device language: de → Deutsch, en → English, else → Français
- Extend language type to "fr" | "en" | "de" in PreferencesProvider
- Add Deutsch option to language SegmentedControl in SettingsScreen

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mkocustos

Copy link
Copy Markdown
Contributor Author

Note: PR #18 adds a language switcher directly to the login screen (fixes #16). It is based on main and currently typed as "fr" | "en". Once this PR is merged, the login screen picker should also be updated to include "de" — a one-line type change in LoginScreen.tsx:

<SegmentedControl<"fr" | "en" | "de">

along with the additional option:

{ label: t("settings.german"), value: "de" }

Auto-detected language was silently overridden by a stale AsyncStorage
value from an older app version. A new `preferences.language.userSet`
flag is now written only when the user actively changes the language —
startup only restores the stored value if this flag is present.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Logarex
Logarex merged commit f918973 into Logarex:main May 18, 2026
@Logarex

Logarex commented May 18, 2026

Copy link
Copy Markdown
Owner

Thank you so much for taking the time to add the German translation.

Your fix for the AsyncStorage stale value overriding the system locale is brilliant. The userSet flag makes perfect sense and is a much cleaner way to handle the fallback logic.

I just pulled the branch locally and tested it on my simulator: everything works flawlessly. The language switch is smooth and the persistence bug is fully resolved.

Merging this right away. Thanks again for this massive contribution to AvoCook!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants