import type { CjkRegion, DigitSystem, HyphenationLocale, LocaleTag, NumeralsSetting } from './types.js'; /** The languages whose hyphenation patterns ship with the engine. */ export declare const HYPHENATION_LOCALES: readonly HyphenationLocale[]; /** The primary language subtag of a BCP 47 tag, lower-cased (`'pt_BR'` → * `'pt'`, `'en-us'` → `'en'`). The key of the built-in string tables. */ export declare function languageOf(tag: unknown): string; /** A configured tag, trimmed, or `undefined` when it is missing, blank or not * a string: such a tag counts as unset wherever a locale falls back. */ export declare function presentTag(tag: unknown): string | undefined; /** Whether `tag` names Chinese, Japanese or Korean (`'zh-Hant'`, `'ja-JP'`, * `'ko'`, in any case, with `-` or `_`). Such a document needs no * hyphenation patterns: hyphenation is off unless the author turns it on * and names a language for the Latin words. */ export declare function isCjkLanguage(tag: unknown): boolean; /** * Whether `tag` names a language set without hyphenation: Chinese, * Japanese and Korean ({@link isCjkLanguage}), and the languages written in * a right-to-left script — Arabic, Persian, Urdu, Hebrew, Yiddish… An * Arabic word is never divided at a line end: its letters join, and the * line is justified with the spaces and kashida instead (arabic-typography * §5); Hebrew books do not divide words either. No patterns ship for any * of them, and asking for none is not a fallback worth reporting. */ export declare function isUnhyphenatedLanguage(tag: unknown): boolean; /** The script of a tag, as `Intl.Locale(tag).maximize()` reads it: `'Hans'` * for `zh`, `zh-CN`, `zh-SG`; `'Hant'` for `zh-TW`, `zh-HK`, `zh-MO` and * `zh-Hant`; `'Latn'` for `en`. `undefined` for a missing or invalid tag. */ export declare function localeScript(tag: unknown): string | undefined; /** The direction text in `tag`'s language runs, from the script the tag * names or implies once maximised (`localeScript`): `'rtl'` for Arabic * (`ar`, `fa`, `ur`, `ps`, `ug`, `az-Arab`), Hebrew (`he`, `yi`), Syriac, * Thaana (`dv`), N'Ko, Adlam (`ff-Adlm`) and the other right-to-left * scripts; `'ltr'` for every other tag, and for a missing or invalid * one. */ export declare function directionOf(tag: unknown): 'ltr' | 'rtl'; /** Whether `tag` names Japanese (`'ja'`, `'ja-JP'`, `'JA_jp'`, * `'ja-Latn'`), in any case, with `-` or `_`: the documents the `japan` * CJK region and the Japanese built-in strings are for. */ export declare function isJapaneseLanguage(tag: unknown): boolean; /** The typographic region of a Chinese or Japanese tag, which decides its * typographic defaults (clreq §1.2: rules follow the region, not the * script). Chinese: CN, SG and MY are `'mainland'`, TW `'taiwan'`, HK and * MO `'hongkong'`; a tag without a region follows its script (`zh-Hant` → * `'taiwan'`, `zh` and `zh-Hans` → `'mainland'`). Every Japanese tag * (`ja`, `ja-JP`, `ja-Jpan`) is `'japan'`: JIS X 4051 and JLReq, not * clreq. `undefined` for any other language (Korean included). */ export declare function cjkRegionOf(tag: unknown): CjkRegion | undefined; /** The script of a Chinese tag once maximised: `'Hant'` for `zh-TW`, * `zh-HK`, `zh-MO` and `zh-Hant`, `'Hans'` for every other Chinese tag * (`zh`, `zh-CN`, `zh-SG`, `zh-Hans`); `undefined` for any other * language. */ export declare function chineseScriptOf(tag: unknown): 'Hans' | 'Hant' | undefined; /** The direction comics are read in by readers of `tag`'s language, when * that language has a convention of its own: `'rtl'` for Japanese (`ja`, * `ja-JP`) and Traditional Chinese (`zh-Hant`, `zh-TW`, `zh-HK`, `zh-MO`), * whose readers turn the pages of a comic, and read its panels, from * right to left. `undefined` for every other language: Simplified Chinese * manhua and Korean manhwa are read left to right today, so the direction * the art was drawn for decides, and a language written right to left * (Arabic, Hebrew) reads its comics in the document's direction. */ export declare function comicsLocaleDirection(tag: unknown): 'rtl' | undefined; /** The key of the built-in string tables for a tag: `'zh-hans'` or * `'zh-hant'` for Chinese (Simplified and Traditional need different * characters: 图/圖, 续/續, 见/見), else the bare language * ({@link languageOf}): `'ja'` for every Japanese tag. */ export declare function stringsKeyOf(tag: unknown): string; /** A BCP 47 tag in its canonical case (`'zh-hant-tw'` → `'zh-Hant-TW'`, * `'PT-br'` → `'pt-BR'`, `'en_us'` → `'en-US'`), script and region kept; * `undefined` for a missing, blank or malformed tag. The form HTML `lang`, * PDF `/Lang` and a Sandbox permalink's `lang=` carry. */ export declare function canonicalLocaleTag(tag: unknown): string | undefined; /** What a document's language is read from: its `locale`, else the * hyphenation tag, and whether its text is shaped in the host's language * (`bodyText.shapingLanguage`). */ interface LanguageSource { locale?: string; bodyText?: { hyphenation?: { tag?: string; locale?: string; }; shapingLanguage?: 'document' | 'host'; }; } /** The `lang` a renderer declares for a resolved document (the HTML * root): its language in canonical form (`zh-Hant-TW`, `ar-EG`, `ca`), * from `locale`, else the hyphenation tag. The canvas declares nothing: * it paints in the language the layout measured in * ({@link shapingLanguageOf}), the document's own unless it asks for the * host's. * * A document shaped in its own language (the default of * `bodyText.shapingLanguage` since postext 1.30, #770) declares it * whatever it is: a font answers with other glyphs under a language (the * Catalan `l·l`, the Turkish `fi`), and the layout measured those * ({@link shapingLanguageOf}). * * A document whose text is shaped in the host's language (`'host'`, what * a configuration stored before `configVersion` 14 reads with) declares * one only when it is Chinese, Japanese or Korean (the browser picks * regional glyph forms from it), or written right to left (the font's * `locl` forms and the fallback font follow it, and assistive technology * reads the text in its language), as up to postext 1.28. */ export declare function renderLangOf(config: LanguageSource | undefined): string | undefined; /** * The language a document's text is measured in (`setMeasureLanguage`), * painted in and embedded in (#764): its own ({@link renderLangOf}), or * the empty tag (no language at all, the same on every host) when its * locale is no tag; and undefined, the host's (the page's on a page, none * in a worker, as up to postext 1.28), for a document that asks for it * (`bodyText.shapingLanguage: 'host'`). The document's own is the default * from postext 1.30 (#770), as it was in 1.29.0 alone, whose canvas and * PDF did not follow the measure; 1.29.1 and 1.29.2 shaped in the host's * unless asked otherwise. */ export declare function shapingLanguageOf(config: LanguageSource | undefined): string | undefined; /** The language of a block or a run that names its own (`{lang=en}`), as * it is measured and painted in a document shaped in its own language: * the tag in canonical form, or as written when it is no tag (a browser * takes any string, and knows no forms for it). */ export declare function shapingTagOf(lang: string): string; /** * The entry of a built-in string table for `tag`, keyed by * {@link stringsKeyOf}: the tag's own, then — for Traditional Chinese — the * Simplified one, then English (`en`). A table only lists the languages it * has strings for. Japanese (`ja`) never borrows a Chinese entry: its * characters and words differ (図 not 图, 続き not 续). */ export declare function stringsFor(table: Readonly>, tag: unknown): T; /** A document language the engine has built-in strings for (figure and * table names, continuation marks, index labels), with its name in the * language itself. */ export interface DocumentLanguage { tag: string; name: string; } /** The document languages with built-in strings, in the order a language * picker lists them: the eight hyphenation languages, then Chinese in * Simplified characters, in Traditional characters (Taiwan) and in * Traditional characters as set in Hong Kong, then Japanese, then Arabic * — bare, as set in Egypt and as set in Morocco. The strings are the same * in the three Arabic entries; the region decides what a regional default * reads from the tag (digits: Arabic-Indic ٠–٩ in the Mashriq, European * 0–9 in the Maghreb; month names in dates). */ export declare const DOCUMENT_LANGUAGES: readonly DocumentLanguage[]; /** * The bundled hyphenation locale for a BCP 47 language tag, or `undefined` * when no patterns ship for its language. Case, `_` separators and any * region, script or variant subtags are ignored: `'es-ES'`, `'es_MX'` and * `'es-419'` give `'es'`, `'pt-BR'` gives `'pt'`, and every English tag * (`'en'`, `'en-GB'`) gives `'en-us'`, the only English patterns. */ export declare function matchHyphenationLocale(tag: string): HyphenationLocale | undefined; /** * {@link matchHyphenationLocale}, falling back to `'en-us'` for a language * with no bundled patterns. The fallback is reported once per tag on the * console, since the text is then hyphenated with another language's rules * (Chinese, Japanese, Korean and the right-to-left languages excepted: they * are set without hyphenation, see {@link isUnhyphenatedLanguage}); * `warn: false` skips the report (hyphenation is off, so no text uses the * patterns). A missing or blank tag gives `'en-us'` silently. */ export declare function hyphenationLocaleFor(tag: LocaleTag, warn?: boolean): HyphenationLocale; /** * Whether two locale tags name the same content language: the same * language, and for a language written in several scripts (Chinese, * Serbian…) the same script once the tags are maximised. `zh-TW` is * `zh-Hant`, `zh` is `zh-Hans`, `es-ES` is `es`; `zh-Hans` is never * `zh-Hant`. Case and `_` separators are ignored; a missing or blank tag * matches nothing. */ export declare function sameContentLocale(a: unknown, b: unknown): boolean; /** * The one of `candidates` that serves `wanted`, or undefined when none is * in its language. An exact tag (case aside) wins; then, for a tag naming * a region, the one that maximises to the same language, script and region * (`zh-TW` finds `zh-Hant`, `en-US` finds `en`); then one in the same * script (a tag with no region first: `zh` finds `zh-Hans`); then any tag * of the language, in another script too: `zh-Hant` finds `zh-Hans` (or a * bare `zh`) only when no candidate is written in Traditional characters. * Ties keep the order of `candidates`. Whether two tags are the same * edition is {@link sameContentLocale}'s question, which the script * always answers. */ export declare function matchContentLocale(candidates: readonly string[], wanted: string): string | undefined; /** Whether `value` names a digit system (`'latn'`, `'arab'`, `'arabext'`). */ export declare function isDigitSystem(value: unknown): value is DigitSystem; /** * The digits a book in `tag` prints its page numbers, list and note numbers * and counters in (`PostextConfig.numerals: 'auto'`): * * - Arabic (`ar`): the Arabic-Indic digits (`'arab'`, ٠–٩) without a region * or with any region but the Maghreb's, whose books print European digits * (`'latn'`: `ar-MA`, `ar-DZ`, `ar-TN`, `ar-LY`, `ar-MR`, `ar-EH`). * CLDR's own defaults give `latn` for a bare `ar` and for `ar-AE`; Arabic * book publishing in the Mashriq and the Gulf prints ٠–٩, and a book is * what this setting is for. * - Persian (`fa`), Pashto (`ps`) and the Urdu of India (`ur-IN`): the * Extended Arabic-Indic digits (`'arabext'`, ۰–۹). The Urdu of Pakistan * (`ur`, `ur-PK`) takes `'latn'`, as CLDR does: Pakistani books print * both, and the European digits are the safe default. * - Every other language: `'latn'`. * * A tag that names its digits in a Unicode extension * (`ar-MA-u-nu-arab`, `fa-u-nu-latn`) has those when they are one of the * three. A missing or invalid tag gives `'latn'`. */ export declare function defaultNumeralsFor(tag: unknown): DigitSystem; /** The digit system of a `numerals` setting for a document in `tag`: the * setting itself when it names one, else (`'auto'`, unset, or a value the * engine does not know) the language's ({@link defaultNumeralsFor}). */ export declare function resolveNumerals(setting: NumeralsSetting | undefined, tag: unknown): DigitSystem; export {}; //# sourceMappingURL=locale.d.ts.map