(locale: Locale<string>)
| 244 | |
| 245 | /** a locale completed from en where it lacks a part */ |
| 246 | export const normalizeLocale = (locale: Locale<string>): Locale.Resolved => { |
| 247 | if (typeof locale !== "object" || locale === null || Array.isArray(locale)) |
| 248 | throwParseError(writeInvalidLocaleObjectMessage(locale)) |
| 249 | // en, once arktype's config has resolved, or before then as it will be, |
| 250 | // so a locale is never kept as complete before there's en to complete it |
| 251 | const en = (defaultLocale ??= $ark.defaultConfig.locale) |
| 252 | if (locale === en) return en |
| 253 | let normalized = normalizedLocales.get(locale) |
| 254 | if (normalized === undefined) { |
| 255 | normalized = completeFrom(en, locale) |
| 256 | normalizedLocales.set(locale, normalized) |
| 257 | } |
| 258 | return normalized |
| 259 | } |
| 260 | |
| 261 | const completeFrom = ( |
| 262 | en: Locale.Resolved, |
no test coverage detected