evOo-local/packages/core/src/text-direction.ts
cynarAI 6c7eed7580 Initial clean evOo-local from f00577b
Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline
(Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/*
packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
2026-09-20 17:15:16 +02:00

17 lines
543 B
TypeScript

export type TextDirection = "ltr" | "rtl";
const RTL_LANGUAGE_PREFIXES = ["ar", "fa", "he", "ur"] as const;
function primaryLanguageTag(localeTag: string): string {
const normalized = localeTag.trim().toLowerCase();
const [primary] = normalized.split(/[-_]/);
return primary ?? normalized;
}
export function textDirectionForLocale(localeTag: string): TextDirection {
const primary = primaryLanguageTag(localeTag);
return RTL_LANGUAGE_PREFIXES.includes(primary as (typeof RTL_LANGUAGE_PREFIXES)[number])
? "rtl"
: "ltr";
}