-
Notifications
You must be signed in to change notification settings - Fork 664
Open
Labels
Description
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.