Skip to content

feat(i18n): add locale-based language support#19

Open
mehmetseyfi wants to merge 3 commits intoSinomor:mainfrom
mehmetseyfi:feature/i18n
Open

feat(i18n): add locale-based language support#19
mehmetseyfi wants to merge 3 commits intoSinomor:mainfrom
mehmetseyfi:feature/i18n

Conversation

@mehmetseyfi
Copy link
Contributor

✨ i18n / Locale Language Support

This PR introduces locale-based internationalization (i18n) support to the project.

🔧 How It Works

Language resolution follows this priority order:

  1. If config.language is set → force that language
  2. Otherwise → use .env LANG
  3. If not available → fallback to en
export const t = initLocale(config?.language);

🧠 Features

  • Automatic language detection via LANG environment variable
  • Safe fallback to en
  • Nested key support (modules.powermenu.sleep)
  • String reference resolution ({common.noMatch})
  • Parameter interpolation ({value}, {name}, etc.)
  • Depth limit to prevent infinite reference loops

📌 Example

t("weather.feelsLike", { value: 24, unit: "°C" });
// → "Feels like 24°C"

📁 Changes

  • Added i18n core under src/lib/locales
  • Defined locale dictionary structure
  • Exported a global t() helper

✅ Backward Compatibility

  • Automatically falls back to en if locale is missing
  • Does not break existing behavior

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.

1 participant

Comments