armenian-transliteration
Version:
Multi-standard Armenian transliteration (BGN/PCGN, ISO 9985, Hübschmann-Meillet, ALA-LC, Russian geographic profiles, Russian proper names, IPA)
112 lines (107 loc) • 5.03 kB
TypeScript
/** Latin-script transliteration standards */
type LatinStandard = "bgn-pcgn" | "iso-9985" | "hubschmann-meillet" | "ala-lc";
/** Cyrillic-script transliteration standards */
type CyrillicStandard = "ru-geo-kt-1974" | "ru-geo-ra-2011" | "ru-proper-vartapetyan-1961" | "ru-phonetic-eastern";
/** IPA transcription standards */
type IpaStandard = "ipa-eastern" | "ipa-western";
/** All supported transliteration standards */
type Standard = LatinStandard | CyrillicStandard | IpaStandard;
/** Transliteration direction. Only `from-armenian` is currently supported. */
type Direction = "from-armenian";
/** Options for the transliterate function */
interface TransliterateOptions {
/** Transliteration standard to use. Default: "bgn-pcgn" */
standard?: Standard;
/** Direction of transliteration. Default: "from-armenian" */
direction?: Direction;
}
/** Position of a token within a word */
type LetterPosition = "initial" | "medial" | "final" | "isolated";
/** Target script for a standard */
type TargetScript = "latin" | "cyrillic" | "ipa";
/** Context condition for position-dependent mapping rules */
interface ContextCondition {
/** Token is at word start (initial or isolated) */
wordInitial?: boolean;
/** Next Armenian token value is one of these (lowercase canonical) */
followedBy?: readonly string[];
/** Previous Armenian token value is one of these (lowercase canonical) */
precededBy?: readonly string[];
/** Token is at a specific position within the word */
position?: LetterPosition | readonly LetterPosition[];
/** Invert: negate the followedBy check (match when NOT followed by) */
notFollowedBy?: readonly string[];
}
/** A context-dependent override rule */
interface ContextRule {
condition: ContextCondition;
target: string;
}
/** Mapping for a single Armenian letter */
interface CharMapping {
/** Armenian letter (lowercase canonical form) */
armenian: string;
/** Default transliteration output (lowercase) */
target: string;
/** When multiple Armenian letters map to the same target, mark one as the reverse default */
reverseDefault?: boolean;
/** Context-dependent overrides, evaluated in order (first match wins) */
contextRules?: readonly ContextRule[];
}
/** Mapping for a multi-character Armenian sequence */
interface SequenceMapping {
/** Armenian sequence (lowercase canonical), e.g. "ու" */
armenian: string;
/** Default transliteration output */
target: string;
/** Reverse default flag */
reverseDefault?: boolean;
/** Context-dependent overrides */
contextRules?: readonly ContextRule[];
}
/** Complete definition of a transliteration standard */
interface TransliterationStandard {
/** Standard identifier */
id: Standard;
/** Human-readable name */
name: string;
/** Target script */
targetScript: TargetScript;
/** Whether this standard supports lossless round-trip */
reversible: boolean;
/** Single-letter mappings (38 Armenian letters) */
charMappings: readonly CharMapping[];
/** Multi-character sequence mappings, ordered longest-first */
sequenceMappings: readonly SequenceMapping[];
/** Armenian punctuation to target punctuation */
punctuation: Record<string, string>;
}
type ProfileStatus = "canonical" | "alias";
type ProfileDomain = "romanization" | "geographic" | "proper-names" | "academic" | "phonemic";
type ProfileSourceKind = "official-standard" | "government-decision" | "geographic-instruction" | "reference-table" | "secondary-reference" | "critical-review" | "terminology-dictionary" | "scholarly-system" | "package-profile";
interface ProfileSource {
title: string;
kind: ProfileSourceKind;
year?: number;
url?: string;
}
interface ProfileMetadata {
id: Standard;
canonicalId: Standard;
status: ProfileStatus;
label: string;
targetLanguage: string | null;
targetScript: TargetScript;
scriptCode: "Latn" | "Cyrl" | "IPA";
domain: ProfileDomain;
authority: string;
year?: number;
aliases: readonly Standard[];
sources: readonly ProfileSource[];
notes: readonly string[];
}
declare const profiles: Record<Standard, ProfileMetadata>;
declare function getProfile(id: Standard): ProfileMetadata;
declare function listProfiles(): readonly ProfileMetadata[];
declare function getProfilesByTargetLanguage(targetLanguage: string): readonly ProfileMetadata[];
export { type CharMapping as C, type Direction as D, type IpaStandard as I, type LatinStandard as L, type ProfileDomain as P, type Standard as S, type TransliterateOptions as T, type ContextCondition as a, type ContextRule as b, type CyrillicStandard as c, type LetterPosition as d, type ProfileMetadata as e, type ProfileSource as f, type ProfileSourceKind as g, type ProfileStatus as h, type SequenceMapping as i, type TargetScript as j, type TransliterationStandard as k, getProfile as l, getProfilesByTargetLanguage as m, listProfiles as n, profiles as p };