Skip to content

Enhanced Locale Configuration Support for LocaleSwitcher #1084

@maxprilutskiy

Description

@maxprilutskiy

Parent Issue

Subtask of #1083

Problem

LocaleSwitcher only accepts string[]. Need support for { en: "English" } and rich configs.

Requirements

1. Add Types

export type LocaleConfig = {
  code: string;
  displayName: string;
  flag?: string;
  nativeName?: string;
};

export type LocalesProp = 
  | string[]
  | Record<string, string>
  | LocaleConfig[];

2. Add Normalization Function

function normalizeLocales(locales: LocalesProp): LocaleConfig[]

Must handle all 3 input formats and return consistent LocaleConfig[].

3. Update LocaleSwitcherProps

Replace locales: string[] with locales: LocalesProp.

Acceptance Criteria

  • ["en", "es"] works unchanged
  • { en: "English", es: "Español" } shows custom names
  • [{ code: "en", displayName: "English" }] works
  • Invalid configs throw descriptive errors
  • Unit tests for all 3 input formats
  • TypeScript inference works correctly

Tests Required

  • String array input
  • Object input
  • LocaleConfig array input
  • Mixed/invalid inputs
  • Type inference

Must complete first - other subtasks depend on these types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions