Skip to content

feat(i18n): add LOCALAI_DEFAULT_LANGUAGE (--default-language) option - #13369

Open
AnythingLinux wants to merge 4 commits into
mudler:masterfrom
AnythingLinux:feat/default-language-config
Open

AnythingLinux wants to merge 4 commits into
mudler:masterfrom
AnythingLinux:feat/default-language-config

Conversation

@AnythingLinux

@AnythingLinux AnythingLinux commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

Closes #13331

Adds a server-level LOCALAI_DEFAULT_LANGUAGE (--default-language) configuration option, allowing administrators and production deployers to define the default UI language without requiring users to configure it manually.

The configured language is applied across the LocalAI web interface, including the login, registration, and home pages, while preserving explicit language preferences selected by users.

Summary of Changes

  • Config & CLI (core/config, core/cli): Added DefaultLanguage to BrandingConfig / RuntimeSettings, including WithDefaultLanguage and runtime settings persistence. Exposed the --default-language CLI flag and LOCALAI_DEFAULT_LANGUAGE environment variable.
  • Public Branding Endpoint (core/http/endpoints/localai/branding.go): Exposed default_language through GET /api/branding, allowing unauthenticated pages such as login and registration to receive the configured language.
  • React i18n Initialization (core/http/react-ui): Integrated the server-configured language from /api/branding using i18n.changeLanguage(...), provided that the value is valid and supported by the frontend.
  • Documentation (docs/content/): Documented the --default-language CLI flag, LOCALAI_DEFAULT_LANGUAGE environment variable, supported locale codes, and language preference precedence.

Language Preference Precedence

The language selection follows this order:

  1. Explicit URL parameter (?lng=<code>)
  2. User's saved preference in localStorage (localai-language)
  3. Server-configured LOCALAI_DEFAULT_LANGUAGE, if valid and supported
  4. Browser language detection, with English (en) as the fallback

Unsupported or invalid server-configured language values are ignored gracefully.

The implementation supports the currently available frontend locales:

en, it, es, de, zh-CN, id, ko, pt-BR, fr, bn

Configuration Example

Set the default language using an environment variable:

services:
  localai:
    environment:
      - LOCALAI_DEFAULT_LANGUAGE=bn

Or use the CLI flag:

local-ai --default-language bn

Notes for Reviewers

  • The default remains unchanged when LOCALAI_DEFAULT_LANGUAGE is not configured.
  • Explicit URL and saved user preferences take precedence over the server default.
  • Invalid or unsupported values do not prevent the UI from loading.
  • Existing authentication methods and behavior remain unchanged.

Checklist

  • Signed commits.
  • Documentation updated in docs/content/ for user-facing changes, or not applicable.

@AnythingLinux
AnythingLinux force-pushed the feat/default-language-config branch from 9a44fce to fa2aa7b Compare November 21, 2026 00:25
@AnythingLinux
AnythingLinux marked this pull request as draft November 21, 2026 00:28
@AnythingLinux
AnythingLinux force-pushed the feat/default-language-config branch 5 times, most recently from f72387a to a3789e6 Compare November 21, 2026 06:42
@AnythingLinux AnythingLinux changed the title Feat/default language config Feat/add LOCALAI_DEFAULT_LANGUAGE (--default-language) option for production deployments Nov 21, 2026
@AnythingLinux AnythingLinux changed the title Feat/add LOCALAI_DEFAULT_LANGUAGE (--default-language) option for production deployments AnythingLinux:feat/default-language-config Nov 21, 2026
@AnythingLinux AnythingLinux changed the title AnythingLinux:feat/default-language-config Feat/default-language-config option for production deployments Nov 21, 2026
@AnythingLinux

AnythingLinux commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi @mudler, this PR is ready for review!

It implements #13331 by adding LOCALAI_DEFAULT_LANGUAGE (--default-language), exposing default_language via GET /api/branding, and initializing i18next across the registration, login, and home views while preserving explicit user preferences (?lng= and localStorage).

Please let me know if any adjustments or additional tests are needed.

Screenshot from 2026-11-22 01-44-56 Screenshot from 2026-11-22 01-44-06 Screenshot from 2026-11-22 01-51-33 Screenshot from 2026-11-22 03-44-10 Screenshot from 2026-11-22 03-44-04

@AnythingLinux
AnythingLinux marked this pull request as ready for review November 21, 2026 19:47
… flag

Signed-off-by: Karim <linuxguns@gmail.com>
Signed-off-by: Karim <linuxguns@gmail.com>
Signed-off-by: Karim <linuxguns@gmail.com>
@AnythingLinux
AnythingLinux force-pushed the feat/default-language-config branch from a3789e6 to 804f824 Compare November 21, 2026 20:02
@AnythingLinux AnythingLinux changed the title Feat/default-language-config option for production deployments feat(i18n): add LOCALAI_DEFAULT_LANGUAGE (--default-language) option Nov 21, 2026

This branch has not been deployed

No deployments
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.

feat(i18n): Add server-configurable default UI language for production deployments

1 participant