Skip to content

[Refactor] settingsStore clamps language to 24 chars without validating against allowed locales #779

Description

@RUKAYAT-CODER

Overview

src/lib/settings/store.ts clamps the language setting to 24 characters as a rough guard but does not validate the value against the SUPPORTED_LANGUAGES list in src/locales/config.ts. An unsupported locale like zz-ZZ (24 chars) passes the check, gets stored, and causes translationManager to fail to load translations, falling back to English silently.

Specifications

Features:

  • Language settings are validated against the SUPPORTED_LANGUAGES allowlist before being stored
  • Unsupported locales are silently replaced with the default language

Tasks:

  • Import SUPPORTED_LANGUAGES from src/locales/config.ts into settingsStore
  • In patchSettings, validate language: if not in SUPPORTED_LANGUAGES, fall back to DEFAULT_LANGUAGE
  • Remove the 24-character clamp since the allowlist check is sufficient
  • Add a test asserting an unsupported locale is replaced with en

Impacted Files:

  • src/lib/settings/store.ts
  • src/locales/config.ts

Acceptance Criteria

  • Setting language to an unsupported locale stores the default language instead
  • Setting language to a valid locale stores it correctly
  • The 24-character length clamp is removed

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions