mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Wesley Luyten <me@wesleyluyten.com>
17 lines
493 B
TypeScript
17 lines
493 B
TypeScript
import { isUndefined } from '../predicate';
|
|
|
|
/** Resolves locale: explicit non-empty value → ambient `lang` → {@link fallback}. */
|
|
export function effectiveLocale(
|
|
explicitLocale: string | undefined,
|
|
ambientLang: string | undefined,
|
|
fallback = 'en'
|
|
): string {
|
|
if (!isUndefined(explicitLocale) && String(explicitLocale).trim() !== '') {
|
|
return explicitLocale;
|
|
}
|
|
if (!isUndefined(ambientLang) && ambientLang.trim() !== '') {
|
|
return ambientLang;
|
|
}
|
|
return fallback;
|
|
}
|