remix-i18next
Version:
The easiest way to translate your Full Stack React Router apps
14 lines (12 loc) • 381 B
text/typescript
import type { Language } from "./parser.js";
/**
* Format a language object into an IETF-like locale string.
*/
export function formatLanguageString(
language: Pick<Language, "code" | "region" | "script">,
): string {
let parts = [language.code];
if (language.script) parts.push(language.script);
if (language.region) parts.push(language.region);
return parts.join("-");
}