Abstract
The tracklang package is provided for package developers who want a simple interface to find out which languages the user has requested through packages such as babel and polyglossia. This package doesn’t provide any translations. Its purpose is simply to track which languages have been requested by the user. Generic TeX code is in tracklang.tex for non-LaTeX users.

If the shell escape is enabled or `\directlua` is available, this package may also be used to query the `LC_ALL` or `LANG` environment variable (see §6). Windows users, who don’t have the locale stored in environment variables, can use texosquery in combination with tracklang. (Similarly if `LC_ALL` or `LANG` don’t contain sufficient information.) In order to use texosquery through the restricted shell escape, you must have at least Java 8 and set up texosquery.cfg appropriately. (See the texosquery manual for further details.)

The fundamental aim of this generic package is to be able to effectively say:

> The user (that is, the document author) wants to use dialects `xx-XX`, `yy-YY-Scrp`, etc in their document. Any packages used by their document that provide multilingual or region-dependent support should do whatever is required to activate the settings for those languages and regions (or warn the user that there’s no support).

Naturally, this is only of use if the locale-sensitive packages use tracklang to pick up this information, which is entirely up to the package authors, but at the moment there’s no standard method for packages to detect the required language and region. The aim of tracklang is to provide that method. In particular, the emphasis is on using ISO language and region codes rather than hard-coding the various language labels used by different language packages.

Related articles: “Localisation of TeX documents: tracklang.” TUGboat, Volume 37 (2016), No. 3, Localisation with tracklang.tex, and tracklang FAQ.

[top]

# List of Tables[link]

[top]
I. User Guide[link]

[top]

# 1. Introduction[link]

When I’m developing a package that provides multilingual support (for example, glossaries) it’s cumbersome trying to work out if the user has requested translations for fixed text. This usually involves checking if babel or translator or polyglossia has been loaded and, if so, what language settings have been used. The result can be a tangled mass of conditional code. The alternative is to tell users to add the language as a document class option, which they may or may not want to do, or to tell them to supply the language settings to every package they load that provides multilingual support, which users are even less likely to want to do.

The tracklang package tries to neaten this up by working out as much of this information as possible for you and providing a command that iterates through the loaded languages. This way, you can just iterate through the list of tracked languages and, for each language, either define the translations or warn the user that there’s no translation for that language.

As from version 1.6.4, tracklang now checks for babel’s `\LocaleForEach` and, if defined, will use that command to iterate over all languages that have currently been loaded either via package option or using `\babelprovide`. Note that “lazy loading” a language via `\selectlanguage` in the document is too late for tracklang to detect.

If polyglossia is loaded, tracklang will check if `\xpg@bcp@loaded` is defined and, if so, will iterate over that list. Older versions of babel and polyglossia that lack these convenient commands are much harder for tracklang to work with.

The tracklang package works fairly well with translator but will additionally assume the root language was also requested when a dialect is specified. So, for example,

    🖹\usepackage[british]{translator}
    \usepackage{tracklang}

is equivalent to

    \usepackage[british]{translator}
    \usepackage[english,british]{tracklang}

This means that `\ForEachTrackedDialect` will iterate through the list “english,british” instead of just “british”, which can result in some redundancy.

If any document class or package options are passed to tracklang, then tracklang won’t bother checking for known language packages. So, if the above example is changed to:

    🖹\documentclass[british]{article}
    \usepackage{translator}
    \usepackage{tracklang}

then the dialect list will just consist of “british” rather than “english,british”. This does, however, mean that if the user mixes class and package options, only the class options will be detected. For example:

    🖹\documentclass[british]{article}
    \usepackage[french]{babel}
    \usepackage{tracklang}

In this case, only the british option will be detected. The user can therefore use the document class option (or tracklang package option) to override the dialect and set the country code (where provided). For example:

    🖹\documentclass[es-MX]{article}
    \usepackage[spanish]{babel}
    \usepackage{tracklang}

This sets the dialect to mexicanspanish and the root language to spanish.

Predefined dialects are listed in Tables 1.1, 1.2 & 1.3. These may be passed in the document class options or used in `\TrackPredefinedDialect`, as illustrated above.

§2 provides brief examples of use for those who want a general overview before reading the more detailed sections. §3 describes generic commands for identifying the document languages. §5 is for package writers who want to add multilingual support to their package and need to know which settings the user has requested through language packages like babel. §6 is for developers of language definition packages who want to help other package writers to detect what languages have been requested.

Table 1.1: Predefined ISO Language-Region Dialects. (ISO tag or dialect label may be used as a package option or with `\TrackPredefinedDialect`)
ISO Tag | Dialect Label | ISO Tag | Dialect Label
--- | --- | --- | ---
cy-GB | GBwelsh | de-AT | austrian
de-AT-1996 | naustrian | de-BE | belgiangerman
de-CH | swissgerman | de-CH-1996 | nswissgerman
de-DE | germanDE | de-DE-1996 | ngermanDE
en-AU | australian | en-CA | canadian
en-GB | british | en-GG | guernseyenglish
en-IE | IEenglish | en-IM | isleofmanenglish
en-JE | jerseyenglish | en-MT | maltaenglish
en-NZ | newzealand | en-US | american
es-AR | argentinespanish | es-BO | bolivianspanish
es-CL | chilianspanish | es-CO | columbianspanish
es-CR | costaricanspanish | es-CU | cubanspanish
es-DO | dominicanspanish | es-EC | ecudorianspanish
es-ES | spainspanish | es-GT | guatemalanspanish
es-HN | honduranspanish | es-MX | mexicanspanish
es-NI | nicaraguanspanish | es-PA | panamaspanish
es-PE | peruvianspanish | es-PR | puertoricospanish
es-PY | paraguayspanish | es-SV | elsalvadorspanish
es-UY | uruguayspanish | es-VE | venezuelanspanish
fr-BE | belgique | fr-CA | canadien
fr-CH | swissfrench | fr-FR | france
fr-GG | guernseyfrench | fr-JE | jerseyfrench
ga-GB | GBirish | ga-IE | IEirish
gd-GB | GBscottish | hr-HR | croatia
hu-HU | hungarian | id-IN | bahasa
it-CH | swissitalian | it-HR | istriacountyitalian
it-IT | italy | it-SI | sloveneistriaitalian
it-SM | sanmarino | it-VA | vatican
ms-MY | malay | mt-MT | maltamaltese
nl-BE | flemish | nl-NL | netherlands
pt-BR | brazilian | pt-PT | portugal
rm-CH | swissromansh | sl-SI | slovenia
Other combinations need to be set with `\TrackLocale` or `\TrackLanguageTag`

Table 1.2: Predefined Root Languages. (†Has an associated territory.) The corresponding tag obtained with ``\GetTrackedLanguageTag`{〈dialect〉}` is shown in parentheses
abkhaz (ab) | afar (aa) | afrikaans (af)
akan (ak) | albanian (sq) | amharic† (am-ET)
anglosaxon (ang) | apache (apa) | arabic (ar)
aragonese† (an-ES) | armenian (hy) | assamese (as)
asturian (ast) | avaric (av) | avestan (ae)
aymara (ay) | azerbaijani (az) | bahasai† (id-IN)
bahasam† (ms-MY) | bambara† (bm-ML) | bashkir (ba)
basque (eu) | belarusian (be) | bengali (bn)
berber (ber) | bihari (bh) | bislama† (bi-VU)
bokmal† (nb-NO) | bosnian (bs) | breton† (br-FR)
bulgarian (bg) | burmese (my) | catalan (ca)
chamorro (ch) | chechen (ce) | chichewa (ny)
chinese (zh) | churchslavonic (cu) | chuvash† (cv-RU)
coptic (cop) | cornish† (kw-GB) | corsican (co)
cree (cr) | croatian (hr) | czech (cs)
danish (da) | divehi† (dv-MV) | dutch (nl)
dzongkha† (dz-BT) | easternpunjabi† (pa-IN) | english (en)
esperanto (eo) | estonian (et) | ewe (ee)
faroese (fo) | farsi (fa) | fijian† (fj-FJ)
finnish (fi) | french (fr) | friulan† (fur-IT)
fula (ff) | galician (gl) | ganda† (lg-UG)
georgian (ka) | german (de) | greek (el)
guarani (gn) | gujarati (gu) | haitian† (ht-HT)
hausa (ha) | hebrew (he) | herero (hz)
hindi (hi) | hirimotu† (ho-PG) | icelandic† (is-IS)
ido (io) | igbo (ig) | interlingua (ia)
interlingue (ie) | inuktitut (iu) | inupiaq (ik)
irish (ga) | italian (it) | japanese (ja)
javanese (jv) | kalaallisut (kl) | kannada† (kn-IN)
kanuri (kr) | kashmiri† (ks-IN) | kazakh (kk)
khmer (km) | kikuyu (ki) | kinyarwanda (rw)
kirundi (rn) | komi† (kv-RU) | kongo (kg)
korean (ko) | kurdish (ku) | kwanyama (kj)
kyrgyz (ky) | lao (lo) | latin (la)
latvian (lv) | limburgish (li) | lingala (ln)
lithuanian (lt) | lsorbian† (dsb-DE) | lubakatanga† (lu-CD)
luxembourgish (lb) | macedonian (mk) | magyar (hu)
malagasy (mg) | malayalam† (ml-IN) | maltese (mt)
manx† (gv-IM) | maori† (mi-NZ) | marathi† (mr-IN)
marshallese† (mh-MH) | mongolian (mn) | nauruan† (na-NR)
navajo† (nv-US) | ndonga (ng) | nepali (ne)
nko (nqo) | norsk (no) | northernndebele (nd)
northernsotho (nso) | nuosu† (ii-CN) | nynorsk† (nn-NO)
occitan (oc) | ojibwe (oj) | oriya (or)
oromo (om) | ossetian (os) | pali (pi)
pashto (ps) | piedmontese† (pms-IT) | polish (pl)
portuges (pt) | quechua (qu) | romanian (ro)
romansh† (rm-CH) | russian (ru) | samin (se)
samoan (sm) | sango (sg) | sanskrit (sa)
sardinian† (sc-IT) | scots (sco) | scottish (gd)
serbian (sr) | shona (sn) | sindhi (sd)
sinhalese† (si-LK) | slovak (sk) | slovene (sl)
somali (so) | southernndebele† (nr-ZA) | southernsotho (st)
spanish (es) | sudanese (su) | swahili (sw)
swati (ss) | swedish (sv) | syriac (syr)
tagalog† (tl-PH) | tahitian† (ty-PF) | tai (tai)
tajik (tg) | tamil (ta) | tatar (tt)
telugu† (te-IN) | thai† (th-TH) | tibetan (bo)
tigrinya (ti) | tonga† (to-TO) | tsonga (ts)
tswana (tn) | turkish (tr) | turkmen (tk)
twi† (tw-GH) | ukrainian† (uk-UA) | undetermined (und)
urdu (ur) | usorbian† (hsb-DE) | uyghur† (ug-CN)
uzbek (uz) | venda† (ve-ZA) | vietnamese (vi)
volapuk (vo) | walloon (wa) | welsh (cy)
westernfrisian† (fy-NL) | wolof (wo) | xhosa (xh)
yiddish (yi) | yoruba (yo) | zhuang† (za-CN)
zulu (zu) |  |

Table 1.3: Predefined Non-ISO Dialects. (†Has an associated territory.) The corresponding language tag obtained with ``\GetTrackedLanguageTag`{〈dialect〉}` is shown in parentheses. If the dialect has a corresponding mapping for the closest matching non-root language `\captions〈dialect〉` or `\date〈dialect〉`, this is also included after the tag following a slash.
acadian (fr) | american† (en-US) | argentinespanish† (es-AR)
australian† (en-AU) | austrian† (de-AT) | bahasa† (id-IN)
belgiangerman† (de-BE) | belgique† (fr-BE) | bolivianspanish† (es-BO)
brazil† (pt-BR) | brazilian† (pt-BR) | british† (en-GB)
canadian† (en-CA) | canadien† (fr-CA) | chilianspanish† (es-CL)
columbianspanish† (es-CO) | costaricanspanish† (es-CR) | croatia† (hr-HR)
cubanspanish† (es-CU) | cymraeg (cy) | deutsch (de)
dominicanspanish† (es-DO) | ecudorianspanish† (es-EC) | elsalvadorspanish† (es-SV)
flemish† (nl-BE) | francais (fr) | france† (fr-FR)
frenchb (fr) | friulano† (fur-IT) | friulian† (fur-IT)
furlan† (fur-IT) | gaeilge (ga) | gaelic (gd)
galicien (gl) | GBirish† (ga-GB) | GBscottish† (gd-GB)
GBwelsh† (cy-GB) | germanb (de) | germanDE† (de-DE)
guatemalanspanish† (es-GT) | guernseyenglish† (en-GG / british) | guernseyfrench† (fr-GG)
honduranspanish† (es-HN) | hungarian† (hu-HU) | IEenglish† (en-IE / british)
IEirish† (ga-IE) | indon† (id-IN) | indonesian† (id-IN)
isleofmanenglish† (en-IM / british) | istriacountycroatian† (hr-HR) | istriacountyitalian† (it-HR)
italy† (it-IT) | jerseyenglish† (en-JE / british) | jerseyfrench† (fr-JE)
kurmanji (ku) | latein (la) | lowersorbian† (dsb-DE)
malay† (ms-MY) | maltaenglish† (en-MT / british) | maltamaltese† (mt-MT)
mexicanspanish† (es-MX) | meyalu† (ms-MY) | naustrian† (de-AT-1996)
nbelgiangerman† (de-BE-1996 / ngerman) | netherlands† (nl-NL) | newzealand† (en-NZ)
ngerman (de-1996) | ngermanb (de-1996 / ngerman) | ngermanDE† (de-DE-1996 / ngerman)
nicaraguanspanish† (es-NI) | nil (und) | norwegian† (no-NO)
nswissgerman† (de-CH-1996 / ngerman) | panamaspanish† (es-PA) | paraguayspanish† (es-PY)
persian (fa) | peruvianspanish† (es-PE) | piemonteis† (pms-IT)
polutoniko (el) | polutonikogreek (el) | portugal† (pt-PT)
portuguese (pt) | puertoricospanish† (es-PR) | romanche (rm-CH)
romansch (rm-CH) | rumantsch (rm-CH) | russianb (ru)
sanmarino† (it-SM) | serbianc (sr-Cyrl) | serbianl (sr-Latn)
sloveneistriaitalian† (it-SI) | sloveneistriaslovenian† (sl-SI / slovenian) | slovenia† (sl-SI / slovenian)
slovenian (sl) | spainspanish† (es-ES) | swissfrench† (fr-CH)
swissgerman† (de-CH) | swissitalian† (it-CH) | swissromansh† (rm-CH)
UKenglish† (en-GB) | ukraine† (uk-UA) | ukraineb† (uk-UA)
uppersorbian† (hsb-DE) | uruguayspanish† (es-UY) | USenglish† (en-US)
valencian (ca) | valencien (ca) | vatican† (it-VA)
venezuelanspanish† (es-VE) |  |

[top]

# 2. Summary of Use[link]

There are three levels of use:

1. 1.document level (code used by document authors);

2. 2.locale-sensitive package level (code for package authors who need to know what languages or locale the document is using, such as glossaries to translate commands like `\descriptionname` or datetime2 to provide localised formats or time zone information);

3. 3.language set-up level (code for packages that set up the document languages, such as babel or polyglossia).

[top]

## 2.1. Document Level[link]

Document level use can be divided into generic TeX use (§2.1.1) and LaTeX-specific use (§2.1.2).

[top]

### 2.1.1. Generic TeX[link]

This section is for generic TeX use. The tracklang files are loaded with `\input`. See §2.1.2 for LaTeX use.

A Unix-like user wants the locale information picked up from the locale environment variable (the tex extension may be omitted):

    🖹\input tracklang.tex % v1.3
    \TrackLangFromEnv
    % load packages that use tracklang for localisation

A Windows user wants the locale information picked up from the operating system (again the tex extension may be omitted):

    🖹\input texosquery.tex
    \input tracklang.tex % v1.3
    \TrackLangFromEnv
    % load packages that use tracklang for localisation

Or (texosquery v1.2)

    🖹\input texosquery.tex % v1.2
    \input tracklang.tex % v1.3

    \TeXOSQueryLangTag{\langtag}
    \TrackLanguageTag{\langtag}
    % load packages that use tracklang for localisation

A Unix-like user who may or may not have texosquery setup to run in the shell escape:

    🖹\input texosquery.tex
    \input tracklang.tex % v1.3

    \ifdefined\TeXOSQueryLangTag
     \TeXOSQueryLangTag{\langtag}
     \TrackLanguageTag{\langtag}
    \else
     \TrackLangFromEnv
    \fi
    % load packages that use tracklang for localisation

A user is writing in Italy in Armenian with a Latin script (Latn) and the arevela variant:

    🖹\input tracklang.tex % v1.3
    \TrackLanguageTag{hy-Latn-IT-arevela}
    % load packages that use tracklang for localisation

A user is writing in English in the UK:

    🖹\input tracklang.tex
    \TrackPredefinedDialect{british}
    % load packages that use tracklang for localisation

Find out information about the current language (supplied in `\languagename`):

    🖹\SetCurrentTrackedDialect{\languagename}
    Dialect: \CurrentTrackedDialect.
    Language: \CurrentTrackedLanguage.
    ISO Code: \CurrentTrackedIsoCode.
    Region: \CurrentTrackedRegion.
    Modifier: \CurrentTrackedDialectModifier.
    Variant: \CurrentTrackedDialectVariant.
    Script: \CurrentTrackedDialectScript.
    Sub-Lang: \CurrentTrackedDialectSubLang.
    Additional: \CurrentTrackedDialectAdditional.
    Language Tag: \CurrentTrackedLanguageTag.

Additional information about the script can be obtained by also loading tracklang-scripts:

    🖹\input tracklang-scripts.tex

The name, numeric code and direction can now be obtained:

    🖹Name: \TrackLangScriptAlphaToName{\CurrentTrackedDialectScript}.
    Numeric:
    \TrackLangScriptAlphaToNumeric{\CurrentTrackedDialectScript}.
    Direction:
    \TrackLangScriptAlphaToDir{\CurrentTrackedDialectScript}.

Test for a specific script (in this case Latn):

    🖹Latin?
    \ifx\CurrentTrackedDialectScript\TrackLangScriptLatn
     Yes
    \else
     No
    \fi

[top]

### 2.1.2. LaTeX[link]

This section is for LaTeX use. See §2.1.1 for generic TeX use.

With newer versions of polyglossia, where `\xpg@bcp@loaded` is defined, you just need to make sure the languages are set before tracklang is loaded:

    🖹\documentclass{article}
    \usepackage{polyglossia}
    \setmainlanguage[variant=uk]{english}
    % load packages that use tracklang for localisation

For older versions of polyglossia where the regional information is required, use recognised class options:

    🖹\documentclass[en-GB]{article}
    \usepackage{polyglossia}
    \setmainlanguage[variant=uk]{english}
    % load packages that use tracklang for localisation

For babel users where the supplied babel dialect label is sufficient, and is passed either through the document class or package options, there’s no need to do anything special:

    🖹\documentclass[british,canadien]{article}
    \usepackage[T1]{fontenc}
    \usepackage{babel}
    % load packages that use tracklang for localisation

With tracklang v1.6.4+ there is now a check for `\LocaleForEach`, which allows tracklang to pick up locales set with `\babelprovide`. For example:

    🖹\documentclass{article}
    \usepackage[T1]{fontenc}
    \usepackage[british]{babel}
    \babelprovide{canadianfrench}
    % load packages that use tracklang for localisation

If the region is important but there’s no babel dialect that represents it, there are several options. The first method is to use the class options recognised by tracklang and the root language labels when loading babel:

    🖹\documentclass[en-IE,ga-IE]{article}
    \usepackage[english,irish]{babel}
    % load packages that use tracklang for localisation

Another method with babel is to use `\TrackLanguageTag` and map the new dialect label to the nearest matching `\captions〈dialect〉`:

    🖹\documentclass{article}

    \usepackage{tracklang}% v1.3
    \TrackLanguageTag{en-MT}
    \SetTrackedDialectLabelMap
     {\TrackLangLastTrackedDialect}{UKenglish}

    \usepackage[UKenglish]{babel}
    % load packages that use tracklang for localisation

This ensures that the `\captionsUKenglish` hook is detected by the localisation packages. This mapping isn’t needed for polyglossia as the caption hooks use the root language label. This mapping also isn’t needed if british is used instead of UKenglish since the en-MT (maltaenglish) predefined dialect automatically sets up a mapping to british. (The default mappings are shown in Table 1.3.)

[top]

## 2.2. Locale-Sensitive Packages[link]

Let’s suppose you are developing a package called mypackage.sty or mypackage.tex and you want to find out what languages the document author has requested. (See also: Using tracklang.tex in Packages with Localisation Features.)

Generic TeX use (the tex extension may be omitted):

    🖹\input tracklang.tex

(Most of the commands used in this section require at least tracklang version 1.3 but 1.4 is better if you want to include the script tag in the ldf files.) Note that tracklang.tex has a check to determine if it’s already been loaded, so you don’t need to worry about that.

LaTeX use:

    🖹\RequirePackage{tracklang}[2019/11/30]% at least v1.4

This will picked up any language options supplied in the document class options and will also detect if babel or polyglossia have been loaded.

(LaTeX) If you want to allow the user to set the locale in the package options:

    🖹\DeclareOption*{\TrackLanguageTag{\CurrentOption}}

This means the user can do, say,

    🖹\usepackage[hy-Latn-IT-arevela]{mypackage}

With at least version 1.4, it’s better to use `\TrackIfKnownLanguage`:

    🖹\DeclareOption*{%
     \TrackIfKnownLanguage{\CurrentOption}%
     {% successful
      \PackageInfo{mypackage}{Tracking language `\CurrentOption'}%
     }%
     {% failed
      \PackageError{mypackage}%
      {Unknown language specification `\CurrentOption'}%
      {You need to supply either a known dialect label
       or a valid language tag}%
     }%
    }

🛈
The rest of the example package in this section uses generic code. If you are using LaTeX, it’s better to replace `\def` and `\ifx` with more appropriate LaTeX commands.

If you want to fetch the locale information from the operating system when the user hasn’t requested a language:

    🖹\AnyTrackedLanguages
    {}
    {% fetch locale information from the operating system
      \ifdefined\TeXOSQueryLangTag
        % texosquery v1.2 available
        \TeXOSQueryLangTag{\langtag}
        \TrackLanguageTag{\langtag}
      \else
        % texosquery v1.2 not available
        \TrackLangFromEnv
      \fi
    }

Set up the defaults if necessary:

    🖹\def\fooname{Foo}
    \def\barname{Bar}

Now load the resource files:

    🖹\AnyTrackedLanguages
    {%
      \ForEachTrackedDialect{\thisdialect}{%
        \TrackLangRequireDialect{mypackage}{\thisdialect}%
      }%
    }
    {}% no tracked languages, default already set up

Each resource file has the naming scheme 〈prefix〉-〈localeid〉.ldf. In this example, the 〈prefix〉 is mypackage. The 〈localeid〉 part may be the language or dialect label (for example, english or british) or a combination of the ISO language and region codes (for example, en-GB or en or GB). As from version 1.4, 〈localeid〉 may also include the script or variant. (See the definition of `\IfTrackedLanguageFileExists` below for further details.)

The simplest scheme is to use the root language label (not the dialect label) for the base language settings and use the ISO codes for regional support.

For example, the file mypackage-english.ldf:

    🖹% identify this file:
    \TrackLangProvidesResource{english}[2016/10/06 v1.0]

    \TrackLangAddToCaptions{%
      \def\fooname{Foo}%
      \def\barname{Bar}%
    }

This sets up appropriate the `\captions〈dialect〉` hook (if it’s found). For other hooks, such as `\date〈dialect〉`, use `\TrackLangAddToHook` or `\TrackLangRedefHook` instead.

With pre-v1.4 versions of tracklang, the script isn’t included in the file search. If it’s needed then either require at least v1.4 or have a base ldf file that tries to load a version for the particular script (which can be accessed with `\CurrentTrackedDialectScript`). Here’s an example for a language with different writing systems. The resource file for Serbian mypackage-serbian.ldf:

    🖹% identify file:
    \TrackLangProvidesResource{serbian}[2016/10/06 v1.0]

    \TrackLangRequestResource{serbian-\CurrentTrackedDialectScript}
    {}% file not found, do something sensible here

The file mypackage-serbian-Latn.ldf sets up the Latin script (Latn):

    🖹\TrackLangProvidesResource{serbian-Latn}[2016/10/06 v1.0]

    \TrackLangAddToCaptions{%
      \def\fooname{...}% provide appropriate Latin translations
      \def\barname{...}%
    }

The file mypackage-serbian-Cyrl.ldf sets up the Cyrillic script (Cyrl):

    🖹\TrackLangProvidesResource{serbian-Cyrl}[2016/10/06 v1.0]

    \TrackLangAddToCaptions{%
      \def\fooname{...}% provide appropriate Cyrillic translations
      \def\barname{...}%
    }

With v1.4+ you just need mypackage-sr-Latn.ldf and mypackage-sr-Cyrl.ldf for the regionless versions.

[top]

## 2.3. Language Packages[link]

Let’s suppose now you’re the developer of a package that sets up the language, hyphenation patterns and so on. It would be really helpful to the locale-sensitive packages in §2.2 to know what languages the document author has requested. You can use the tracklang package to identify this information by tracking the requested localisation, so that other packages can have a consistent way of querying it. (See also: Integrating tracklang.tex into Language Packages.)

Generic use:

    🖹\input tracklang

Alternative LaTeX use:

    🖹\RequirePackage{tracklang}[2019/11/30]% v1.4

Unlike `\input`, `\RequirePackage` will allow tracklang to pick up the document class options, but using `\RequirePackage` will also trigger the tests for known language packages. (If you want to find out if tracklang has already been loaded and locales have already been tracked, you can use the same code as in the previous section.)

When a user requests a particular language through your package, the simplest way of letting tracklang know about it is to use `\TrackPredefinedDialect` or `\TrackLanguageTag`. For example, if the user requests british, that’s a predefined dialect so you can just do:

    🖹\TrackPredefinedDialect{british}

Alternatively

    🖹\TrackLanguageTag{en-GB}

If your package uses caption hooks, then you can set up a mapping between tracklang’s internal dialect label and your caption label. For example, let’s suppose the closest match to English used in Malta (en-MT) is the dialect UKenglish (for example, the date format is similar between GB and MT):

    🖹\TrackLanguageTag{en-MT}
    \SetTrackedDialectLabelMap{\TrackLangLastTrackedDialect}{UKenglish}
    \def\captionsUKenglish{%
      \def\contentsname{Contents}%
      % ...
    }

(The predefined maltaenglish option provided by tracklang automatically sets the mapping to british, but the above method will change that mapping to UKenglish.)

This now means that `\TrackLangAddToHook` and `\TrackLangRedefHook` commands can find your language hooks. You don’t need the map if your dialect label is the same as tracklang’s root language label for that locale. For example:

    🖹\TrackLanguageTag{en-MT}
    \def\captionsenglish{%
      \def\contentsname{Contents}%
      % ...
    }

When the user switches language through commands like `\selectlanguage` it would be useful to also use ``\SetCurrentTrackedDialect`{〈dialect〉}` to make it easier for the document author or locale-sensitive packages to pick up the current locale. The 〈dialect〉 argument may be tracklang’s internal dialect label or the dialect label you assigned with `\SetTrackedDialectLabelMap`. It may also be the root language label, in which case tracklang will search for the last dialect to be tracked with that language. For example:

    🖹\def\selectlanguage#1{%
      \SetCurrentTrackedDialect{#1}%
      % set up hyphenation patterns etc
    }

See the example in §2.1 or the example in Integrating tracklang.tex into Language Packages.

[top]

# 3. Generic Use[link]

For plain TeX you can input tracklang.tex:

    🖹\input tracklang

or for TeX formats that have an argument form for `\input`:

    🖹\input{tracklang}

As from version 1.3, you don’t need to change the category code of `@` before loading tracklang.tex as it will automatically be changed to 11 and switched back at the end (if required).

The LaTeX package tracklang.sty inputs the generic TeX code in tracklang.tex, but before it does so it defines

📌
``\@tracklang@declareoption`{〈dialect〉}`
to

    \DeclareOption{〈dialect〉}{\TrackPredefinedDialect{〈dialect〉}}

If `\@tracklang@declareoption` isn’t defined when tracklang.tex is input, it will be defined to ignore its argument.

This means that all the predefined languages and dialects (Tables 1.1, 1.2 & 1.3) automatically become package options, so the tracklang.sty package can pick up document class options and add them to tracklang’s internal list of tracked document languages.

As from version 1.6.3, the LaTeX package also has options verbose and noverbose to switch on and off verbose mode. As from version 1.6.5, there are also warn and nowarn settings to switch on (default) and off warnings. This means that these options can be picked up if they are used as document class options or passed to tracklang before it’s first loaded.

If you’re not using LaTeX, package options aren’t available although you can redefine `\@tracklang@declareoption` to use something analogous to `\DeclareOption`, if appropriate. Otherwise, the document languages need to be explicitly identified (using any of the following commands) so that tracklang knows about them.

📌
``\TrackPredefinedDialect`{〈dialect label〉}`
This will add the predefined dialect and its associated ISO codes to the list of tracked document languages. The 〈dialect label〉 may be any of those listed in Tables 1.1, 1.2 & 1.3.

For example:

    🖹\input tracklang
    \TrackPredefinedDialect{british}

is the Plain TeX alternative to:

    🖹\documentclass[british]{article}
    \usepackage{tracklang}

Note that it’s impractical to define every possible language and region combination as it would significantly slow the time taken to load tracklang so, after version 1.3, I don’t intend adding any new predefined dialects. As from version 1.3, if you want to track a dialect that’s not predefined by tracklang, then you can use:

📌
``\TrackLocale`{〈locale〉}`
If 〈locale〉 is a recognised dialect, this is equivalent to using `\TrackPredefinedDialect`, otherwise 〈locale〉 needs to be in one the following formats:

- •〈ISO lang〉
- •〈ISO lang〉`@`〈modifier〉
- •〈ISO lang〉`-`〈ISO country〉
- •〈ISO lang〉`-`〈ISO country〉`@`〈modifier〉

where 〈ISO lang〉 is the ISO 639-1 or 639-2 code identifying the language (lower case), 〈ISO country〉 is the 3166-1 ISO code identifying the territory (upper case) and 〈modifier〉 is the modifier or variant. The hyphen (`-`) may be replaced by an underscore character (`_`). Code-set information in the form ``.`〈codeset〉` may optionally appear before the modifier. For example, `de`-`DE`.`utf8`@`new` (modifier is new) or `en`-`GB`.`utf8` (modifier is missing). The code-set will be ignored if present, but it won’t interfere with the parsing.

For example:

    🖹\TrackLocale{de-NA@new}

indicates German in Namibia using the new spelling.

ℹ
If a language has different ISO 639-2 (T) and 639-2 (B) codes, then the “T” form should be used. (So for the above example, `deu` may be used instead of `de`, but `ger` won’t be recognised.)

Alternatively, you can use

📌
``\TrackLanguageTag`{〈tag〉}`
where 〈tag〉 is a regular, well-formed language tag or a recognised dialect label. (Irregular grandfather tags aren’t recognised.) Note that the tag must start with a language identifier and can’t simply be a region code (use “und” if the language is unknown). This command will fully expand 〈tag〉. A warning is issued if the tag is empty.

If you want to first check that 〈tag〉 includes a valid language code, then you can instead use:

📌
``\TrackIfKnownLanguage`{〈tag〉}{〈success code〉}{〈fail code〉}`
This will only track 〈tag〉 (and then do 〈success code〉) if 〈tag〉 starts with a valid language code (or is a predefined dialect) otherwise it will do 〈fail code〉. Both `\TrackLanguageTag` and `\TrackIfKnownLanguage` will check if 〈tag〉 is a predefined option. (This saves parsing the tag if it’s recognised.)

For example:

    🖹\TrackLanguageTag{hy-Latn-IT-arevela}
    Latn-ME: \TrackIfKnownLanguage{Latn-ME}{success}{fail}.
    brazilian: \TrackIfKnownLanguage{brazilian}{success}{fail}.

This will track hy-Latn-IT-arevela and brazilian (pt-BR) but not Latn-ME (because it doesn’t contain a valid language code) even though it’s a valid script and country code. The above is just for illustrative purposes. Typically the language tracking isn’t performed within the document text.

The datetime2 package assumes that any unknown package option is a language identifier. It could simply do:

    \TrackLanguageTag{\CurrentOption}

but users can make mistakes sometimes and this won’t provide any helpful information if they, for example, misspelt a package option or forgot the “〈key〉=” part of a 〈key〉=〈value〉 setting. Instead (as from v1.5.5) datetime2 now does:

    \TrackIfKnownLanguage{\CurrentOption}
    {...}% known language
    {\PackageError{...}{...}{...}}

This will now give the user some guidance.

If 〈tag〉 contains a sub-language tag, this will be set as the 639-3 code for the dialect label. Note that this is different to the root language codes which are set using the language label. For example:

    🖹\TrackLanguageTag{zh-cmn-Hans-CN}

creates a new dialect with the label `zhcmnHansCN`. The root language chinese has the 639-1 code zh and the dialect `zhcmnHansCN` has the ISO 639-3 code cmn.

    🖹ISO 639-1: \TrackedIsoCodeFromLanguage{639-1}{chinese}.
    ISO 639-3: \TrackedIsoCodeFromLanguage{639-3}{zhcmnHansCN}.

Version 1.2 of texosquery provides the command `\TeXOSQueryLangTag`, which may be used to fetch the operating system’s regional information as a language tag. These commands can be used as follows:

    🖹\input tracklang % v1.3
    \input texosquery % v1.2

    \TeXOSQueryLangTag{\langtag}
    \TrackLanguageTag{\langtag}

(If the shell escape is disabled, `\langtag` will be empty, which will trigger a warning but no errors.)

Some of the predefined root language options listed in Table 1.2 have an associated region (denoted by †). If `\TrackLocale` is used with just the language ISO code, no region is tracked for that language. For example

    🖹\TrackLocale{manx}

will track the IM (Isle of Man) ISO 3166-1 code but

    🖹\TrackLocale{gv}

won’t track the region. Similarly for `\TrackLanguageTag`.

(New to version 1.3.) There’s a similar command to `\TrackLocale` that doesn’t take an argument:

📌
``\TrackLangFromEnv``
If the shell escape has been enabled or `\directlua` is available, this will try to get the language information from the system environment variables `LC_ALL` or `LANG` and, if successful, track that.

Since tracklang is neither able to look up the POSIX locale tables nor interpret file locales, if the result is `C` or `POSIX` or starts with a forward slash `/` then the locale value is treated as empty.

ℹ
Not all operating systems use environment variables for the system locale information. For example, Windows stores the locale information in the registry. In which case, consider using texosquery.

If the operating system locale can’t be obtained from environment variables, then tracklang will use `\TeXOSQueryLocale` as a fallback if texosquery has been loaded. Since texosquery requires both the shell escape and the Java runtime environment, tracklang doesn’t automatically load it.

Plain TeX example:

    🖹\input texosquery
    \input tracklang
    \TrackLangFromEnv

Document build:

    〉_etex --shell-escape 〈filename〉

LaTeX example:

    🖹\usepackage{texosquery}
    \usepackage{tracklang}
    \TrackLangFromEnv

Document build:

    〉_pdflatex --shell-escape 〈filename〉

If the locale can’t be determined, there will be warning messages. These can be suppressed using

📌
``\TrackLangShowWarningsfalse``
or switched back on again using
📌
``\TrackLangShowWarningstrue``

For example, I have the environment variable `LANG` set to `en`_`GB`.`utf8` on my Linux system so instead of

    🖹\TrackPredefinedDialect{british}

I can use

    🖹\TrackLangFromEnv

With LaTeX documents I can do

    🖹\documentclass{article}
    \usepackage{tracklang}
    \TrackLangFromEnv

However, this only helps subsequently loaded packages that use tracklang to determine the required regional settings. For example:

    🖹\documentclass{article}
    \usepackage{tracklang}
    \TrackLangFromEnv
    \usepackage[useregional]{datetime2}

In my case, with the `LANG` environment variable set to `en`_`GB`.`utf8` and the shell escape enabled, this automatically switches on the en-GB date style. Naturally this doesn’t help locale-sensitive packages that don’t use tracklang.

The `\TrackLangFromEnv` command also incidentally sets `\TrackLangEnv` to the value of the environment variable or empty if the query was unsuccessful (for example, the shell escape is unavailable).

If the command:

📌
``\TrackLangEnv``

user defined
is already defined before `\TrackLangFromEnv` is used, then the environment variable won’t be queried and the value of `\TrackLangEnv` will be parsed instead.

ℹ
The parser which splits the locale string into its component parts first tries splitting on the underscore `_` with its usual category code 8, then tries splitting on a hyphen `-` with category code 12, and then tries splitting on the underscore `_` with category code 12.

For example:

    🖹\def\TrackLangEnv{en-GB}
    \TrackLangFromEnv

This doesn’t perform a shell escape since `\TrackLangEnv` is already defined. In this case, you may just as well use:

    🖹\TrackLocale{en-GB}

(unless you happen to additionally require the component commands that are set by `\TrackLangFromEnv`, see below.)

If the shell escape is unavailable (for example, your TeX installation prohibits it), you can set this value when you invoke TeX. For example, if the document file is called myDoc.tex (and it’s in Plain TeX):

    〉_tex "\\def\\TrackLangEnv{$LANG}\\input myDoc"

The `\TrackLangFromEnv` command also happens to store the component parts of the environment variable value in the following commands. (These aren’t provided by `\TrackLocale`.) If the information is unavailable, the relevant commands will be set to empty.

The language code is stored in:

📌
``\TrackLangEnvLang``

The territory (if present) is stored in:

📌
``\TrackLangEnvTerritory``

The code-set (if present) is stored in:

📌
``\TrackLangEnvCodeSet``

The modifier (if present) is stored in:

📌
``\TrackLangEnvModifier``

If you want to query the language environment, but don’t want to track the result, you can just use:

📌
``\TrackLangQueryEnv``
This only tries to fetch the value of the language environment variable (and use texosquery as a fallback, if it has been loaded). It doesn’t try to parse the result. The result is stored in `\TrackLangEnv` (empty if unsuccessful). Unlike `\TrackLangFromEnv`, this doesn’t check if `\TrackLangEnv` already exists. A warning will occur if the shell escape is unavailable. For systems that store the locale information in environment variables, this is more efficient than using texosquery’s `\TeXOSQueryLocale` command (which is what’s used as the fallback).

The above queries `LC_ALL` and, if that is unsuccessful, then queries `LANG` (before optionally falling back on texosquery). If you want another environment variable tried after `LC_ALL` and before `LANG`, you can instead use:

📌
``\TrackLangQueryOtherEnv`{〈env-name〉}`
For example, to also query `LC_MONETARY`:

    🖹\TrackLangQueryOtherEnv{LC_MONETARY}

Since this sets `\TrackLangEnv`, you can use it before `\TrackLangFromEnv`. For example:

    🖹\TrackLangQueryOtherEnv{LC_MONETARY}
    \TrackLangFromEnv

Remember that if you only want to do the shell escape if `\TrackLangEnv` hasn’t already been defined, you can test for this first:

    🖹\ifdefined\TrackLangEnv
    \else
      \TrackLangQueryOtherEnv{LC_MONETARY}
    \fi
    \TrackLangFromEnv

It’s also possible to just parse the value of `\TrackLangEnv` without tracking the result using:

📌
``\TrackLangParseFromEnv``
This is like `\TrackLangFromEnv` but assumes that `\TrackLangEnv` has already been set and doesn’t track the result. The component parts are stored as for `\TrackLangFromEnv`.

Example (Plain TeX):

    🖹\input tracklang

    \def\TrackLangEnv{fr-BE.utf8@euro}

    \TrackLangParseFromEnv

    Language: \TrackLangEnvLang.
    Territory: \TrackLangEnvTerritory.
    Codeset: \TrackLangEnvCodeSet.
    Modifier: \TrackLangEnvModifier.
    Any tracked languages? \AnyTrackedLanguages{Yes}{No}.

This produces:
🖺
Language: fr. Territory: BE. Codeset: utf8. Modifier: euro. Any tracked languages? No.

Compare this with:

    🖹\input tracklang

    \def\TrackLangEnv{fr-BE.utf8@euro}

    \TrackLangFromEnv

    Language: \TrackLangEnvLang.
    Territory: \TrackLangEnvTerritory.
    Codeset: \TrackLangEnvCodeSet.
    Modifier: \TrackLangEnvModifier.
    Any tracked languages? \AnyTrackedLanguages{Yes}{No}.
    Tracked dialect(s):%
    \ForEachTrackedDialect{\thisdialect}{\space\thisdialect}.

This produces:

🖺
Language: fr. Territory: BE. Codeset: utf8. Modifier: euro. Any tracked languages? Yes. Tracked dialect(s): belgique.

If `\TrackLangFromEnv` doesn’t recognise the given language and territory combination, it will define a new dialect and add that.

For example, tracklang doesn’t recognise `en-BE`, so the sample document below defines a new dialect labelled `enBEeuro`:

    🖹\input tracklang

    \def\TrackLangEnv{en-BE.utf8@euro}

    \TrackLangFromEnv

    Language: \TrackLangEnvLang.
    Territory: \TrackLangEnvTerritory.
    Codeset: \TrackLangEnvCodeSet.
    Modifier: \TrackLangEnvModifier.
    Any tracked languages? \AnyTrackedLanguages{Yes}{No}.
    Tracked dialect(s):%
    \ForEachTrackedDialect{\thisdialect}{\space\thisdialect}.

This now produces:
🖺
Language: en. Territory: BE. Codeset: utf8. Modifier: euro. Any tracked languages? Yes. Tracked dialect(s): enBEeuro.

[top]

# 4. Supplementary Packages[link]

In addition to the main tracklang.tex file and tracklang.sty LaTeX wrapper, the tracklang package also provides supplementary files for region and script mappings.

tracklang-region-codes.tex
This file is only loaded if a mapping is required between numeric and alphabetic region codes. If `\TrackLanguageTag` encounters a numeric region code, it will automatically input tracklang-region-codes.tex, if it hasn’t already been input. This file provides the following commands.

📌
``\TrackLangAlphaIIToNumericRegion`{〈alpha-2 code〉}`
Expands to the numeric code corresponding to the given alpha-2 code or empty if no mapping has been supplied.

📌
``\TrackLangNumericToAlphaIIRegion`{〈numeric code〉}`
Expands to the alpha-2 code corresponding to the given numeric code or empty if no mapping has been supplied.

📌
``\TrackLangIfKnownAlphaIIRegion`{〈alpha-2 code〉}{〈true〉}{〈false〉}`
Expands to 〈true〉 if there’s an alpha-2 to numeric region code mapping, otherwise expands to 〈false〉.

📌
``\TrackLangIfKnownNumericRegion`{〈numeric code〉}{〈true〉}{〈false〉}`
Expands to 〈true〉 if there’s a numeric to alpha-2 region code mapping, otherwise expands to 〈false〉.

📌
``\TrackLangAlphaIIIToNumericRegion`{〈alpha-3 code〉}`
Expands to the numeric code corresponding to the given alpha-3 code or empty if no mapping has been supplied.

📌
``\TrackLangNumericToAlphaIIIRegion`{〈numeric code〉}`
Expands to the alpha-3 code corresponding to the given numeric code or empty if no mapping has been supplied.

📌
``\TrackLangIfKnownAlphaIIIRegion`{〈alpha-3 code〉}{〈true〉}{〈false〉}`
Expands to 〈true〉 if there’s an alpha-3 to numeric region code mapping, otherwise expands to 〈false〉.

Mappings are established with:

📌
``\TrackLangRegionMap`{〈numeric〉}{〈alpha-2〉}{〈alpha-3〉}`
Predefined mappings are listed in Table A.1.

When tracklang-region-codes.tex is input, it can load additional files that provide supplementary mappings.

📌
``\TrackLangAddExtraRegionFile`{〈file〉}`
This command adds the supplied 〈file〉 to the list of extra region code files that should be input by tracklang-region-codes.tex, unless tracklang-region-codes.tex has already been input, in which case 〈file〉 will be input straight away.

tracklang-scripts.tex
The tracklang-scripts package provides information about ISO 15924 scripts. The file isn’t automatically loaded. If you want to use any of the commands provided in it you need to input it.

Plain TeX:

    🖹\input tracklang-scripts

There’s a simple wrapper package tracklang-scripts.sty for LaTeX users:

    🖹\usepackage{tracklang-scripts}

📌
``\TrackLangScriptMap`{〈letter code〉}{〈numeric code〉}{〈script name〉}{〈direction〉}{〈parent script〉}`
Defines a mapping. The first argument is the four letter alpha code, such as Latn or Cyrl. The second argument is the numeric code. The third argument is the script’s name, for example “Imperial Aramaic”. The fourth argument is the direction, which may be one of: LR (left-to-right), RL (right-to-left), TB (top-to-bottom), varies or inherited. The 〈parent〉 argument is for the parent writing system, which may be left blank (currently unsupported).

This command defines:

📌
``\TrackLangScript〈Code〉``
which expands to 〈Code〉 for use with `\IfTrackedDialectIsScriptCs`.

See Table A.2 for a summary of all the mappings that are provided by the file tracklang-scripts.tex.

📌
``\TrackLangScriptAlphaToNumeric`{〈alpha code〉}`
Expands to the numeric code corresponding to the given alpha code or empty if no mapping.

📌
``\TrackLangScriptIfKnownAlpha`{〈alpha code〉}{〈true〉}{〈false〉}`
Expands to 〈true〉 if there is a known alpha to numeric mapping or 〈false〉 otherwise.

📌
``\TrackLangScriptNumericToAlpha`{〈numeric code〉}`
Expands to the alpha code corresponding to the given numeric code or empty if no mapping.

📌
``\TrackLangScriptIfKnownNumeric`{〈numeric code〉}{〈true〉}{〈false〉}`
Expands to 〈true〉 if there is a known numeric to alpha mapping or 〈false〉 otherwise.

📌
``\TrackLangScriptAlphaToName`{〈alpha code〉}`
Expands to the name corresponding to the given alpha code or empty if no mapping.

📌
``\TrackLangScriptAlphaToDir`{〈alpha code〉}`
Expands to the direction corresponding to the given alpha code or empty if no mapping.

📌
``\TrackLangScriptSetParent`{〈alpha code〉}{〈parent alpha code〉}`
Sets the parent for the given alpha code.

📌
``\TrackLangScriptGetParent`{〈alpha code〉}`
Expands to the parent for the given alpha code or empty if no mapping.

📌
``\TrackLangScriptIfHasParent`{〈alpha code〉}{〈true〉}{〈false〉}`
Expands to 〈true〉 if the given alpha code has a parent or to 〈false〉 otherwise. Note that if a parent is explicitly set to empty with `\TrackLangScriptSetParent` then it will be considered defined, but if the 〈parent〉 argument was empty in `\TrackLangScriptMap`, then it will be undefined.

📌
``\TrackLangAddExtraScriptFile`{〈file〉}`
This command adds 〈file〉 to the list of extra script files that should be input by tracklang-scripts.tex, unless tracklang-scripts.tex has already been input, in which case 〈file〉 will be input straight away.

[top]

# 5. Detecting the User’s Requested Languages[link]

The tracklang package tries to track the loaded languages and the option names used to identify those languages. For want of a better term, the language option names are referred to as dialects even if they’re only a synonym for the language rather than an actual dialect. For example, if the user has requested british, the root language label is english and the dialect is british, whereas if the user requested UKenglish, the root language label is english and the dialect is UKenglish. The exceptions to this are the tracklang package options that have been specified in the form 〈iso lang〉-〈iso country〉 (listed in Table 1.2). For example, the package option en-GB behaves as though the user requested the package option british.

If `\TrackLocale` or `\TrackLangFromEnv` are used and the locale isn’t recognised a new dialect is created with the label formed from the ISO codes (and modifier, if present). Similarly for `\TrackLanguageTag` a new dialect is created with a label that’s essentially the language tag without the hyphen separators. For example,

    🖹\TrackLocale{xx-YY}

will add a new dialect with the label `xxYY`,

    🖹\TrackLocale{xx-YY@mod}

will add a new dialect with the label `xxYYmod` and

    🖹\TrackLanguageTag{xx-Latn-YY}

will add a new dialect with the label `xxLatnYY`.

ℹ
If `\TrackLocale` or `\TrackLangFromEnv` find a modifier, the value will be sanitized to allow it to be used as a label. If the modifier is set explicitly using `\SetTrackedDialectModifier`, no sanitization is performed.

In addition to the root language label and the dialect identifier, many of the language options also have corresponding ISO codes. In most cases there is an ISO 639-1 or an ISO 639-2 code (or both), and in some cases there is an ISO 3166-1 code identifying the dialect region. Where a language has different ISO 639-2 (T) and 639-2 (B) codes, the “T” version is assumed.

When the tracklang.sty LaTeX package is loaded, it first attempts to find the language options through the package options supplied to tracklang. This means that any languages that have been supplied in the document class options should get identified (provided that the document class has used the standard option declaration mechanism). If no languages have been supplied in this way, tracklang.sty then attempts to identify language settings in the following order:

1. 1.if `\LocaleForEach` is defined (babel), tracklang will use it to iterate over each dialect label and fetch the associated BCP 47 tag;

2. 2.if `\bbl@loaded` is defined (babel), tracklang will iterate over each label in that command definition;

3. 3.if `\trans@languages` is defined (translator), tracklang will iterate over each label in that command definition;

4. 4.if ngerman has been loaded, the ngerman dialect will be tracked;

5. 5.if german has been loaded, the german root language will be tracked;

6. 6.if polyglossia has been loaded:

   1. (a)if `\xpg@bcp@loaded` has been defined, tracklang will iterate over the BCP 47 tags in that command definition;

   2. (b)if `\xpg@loaded` has been defined, tracklang will iterate over each language label in that command definition;

   3. (c)tracklang will iterate over all tracklang options and test if the root language has been loaded.

The check for ngerman/german is retained for backward-compatibility.

Each identified language and dialect is added to the tracked language and tracked dialect lists. Note that the tracked language and tracked dialect are labels rather than proper nouns. If a dialect label is identical to its root language label, the label will appear in both lists.

You can check whether or not any languages have been detected using:

📌
``\AnyTrackedLanguages`{〈true〉}{〈false〉}`
This will do 〈true〉 if one or more languages have been tracked otherwise it will do 〈false〉. (Each detected dialect will automatically have the root language label added to the tracked language list, if it’s not already present.)

You can check whether or not any regions have been detected using:

📌
``\AnyTrackedRegions`{〈true〉}{〈false〉}`
This will do 〈true〉 if one or more regions have been tracked otherwise it will do 〈false〉.

If you want to find out if any of the tracked dialects matches a particular language tag, you can use:

📌
``\GetTrackedDialectFromLanguageTag`{〈tag〉}{〈cs〉}`
If successful, the supplied control sequence 〈cs〉 is set to the dialect label, otherwise 〈cs〉 is set to empty. The test is for an exact match on the root language, script, sub-language, variant and region. The control sequence 〈cs〉 will be empty if none of the tracked dialects matches all five of those elements. (If the script isn’t given explicitly, the default for that language is assumed.) In the event that 〈cs〉 is empty, you can now (as from v1.3.6) get the closest match with:
📌
``\TrackedDialectClosestSubMatch``
(which is set by `\GetTrackedDialectFromLanguageTag`). This will be empty if no tracked dialects match on the root language or if there’s a tracked dialect label that exactly matches the label formed by concatenating the language code, sub-language, script, region, modifier and variant.

For example (Plain TeX):

    🖹\input tracklang
    \TrackLanguageTag{en-826}
    Has en-Latn-GB been tracked?
    \GetTrackedDialectFromLanguageTag{en-Latn-GB}{\thisdialect}%
    \ifx\thisdialect\empty
     No!
    \else
     Yes! Dialect label: \thisdialect.
    \fi
    \bye

This matches because the territory code 826 is recognised as equivalent to the code GB, and the default script for english is Latn. In this case, the dialect label is british. Note that this doesn’t require the use of `\TrackLanguageTag` to track the dialect. It also works if the dialect has been tracked using other commands, such as `\TrackLocale`.

Here’s an example that doesn’t have an exact match, but does have a partial match:

    🖹\input tracklang
    \TrackLanguageTag{de-CH-1996}
    Has de-DE-1996 been tracked?
    \GetTrackedDialectFromLanguageTag{de-DE-1996}{\thisdialect}%
    \ifx\thisdialect\empty
     No!
      \ifx\TrackedDialectClosestSubMatch\empty
        No match on root language.
      \else
        Closest match: \TrackedDialectClosestSubMatch.
      \fi
    \else
     Yes! Dialect label: \thisdialect.
    \fi
    \bye

In this case the result is:
🖺
Has de-DE-1996 been tracked? No! Closest match: nswissgerman.

You can iterate through each tracked dialect using:

📌
``\ForEachTrackedDialect`{〈cs〉}{〈body〉}`
At the start of each iteration, this sets the control sequence 〈cs〉 to the tracked dialect and does 〈body〉.

You can iterate through each tracked language using:

📌
``\ForEachTrackedLanguage`{〈cs〉}{〈body〉}`
At the start of each iteration, this sets the control sequence 〈cs〉 to the tracked language and does 〈body〉.

You can iterate through each tracked region using:

📌
``\ForEachTrackedRegion`{〈cs〉}{〈body〉}`

The above for-loops use the same internal mechanism as LaTeX’s `\@for` loop. Since this isn’t defined by TeX, a similar command (`\@tracklang@for`) will be defined that works in the same way.

The provided control sequence 〈cs〉 is updated at the start of each iteration to the current element. The loop is terminated when this control sequence is set to `\@nil`. This special control sequence should never been used as it’s just a marker and isn’t actually defined. If you get an error message stating that `\@nil` is undefined, then it’s most likely due to a loop control sequence being used outside the loop. This can occur if the loop contains code that isn’t expanded until later. For example, if the loop code includes `\AtBeginDocument`, you need to ensure that the loop control sequence is expanded before being added to the hook.

You can test if a root language has been detected using:

📌
``\IfTrackedLanguage`{〈language-label〉}{〈true〉}{〈false〉}`
where 〈language-label〉 is the language label. If true, this does 〈true〉 otherwise it does 〈false〉.

You can test if a particular dialect has been detected using:

📌
``\IfTrackedDialect`{〈dialect-label〉}{〈true〉}{〈false〉}`
where 〈dialect-label〉 is the dialect label. If the root language was explicitly specified, then it will also be detected as a dialect.

For example:

    🖹\documentclass[british,dutch]{article}

    \usepackage{tracklang}

    \begin{document}
    ``english'' \IfTrackedDialect{english}{has}{hasn't} been specified.

    ``british'' \IfTrackedDialect{british}{has}{hasn't} been specified.

    ``flemish'' \IfTrackedDialect{flemish}{has}{hasn't} been specified.

    ``dutch'' \IfTrackedDialect{dutch}{has}{hasn't} been specified.

    ``english'' or an English variant
    \IfTrackedLanguage{english}{has}{hasn't} been specified.
    \end{document}

This produces:
🖺
“english’’ hasn’t been specified.

“british’’ has been specified.

“flemish’’ hasn’t been specified.

“dutch’’ has been specified.

“english’’ or an English variant has been specified.

You can find the root language label for a given tracked dialect using:

📌
``\TrackedLanguageFromDialect`{〈dialect〉}`
If 〈dialect〉 hasn’t been defined this does nothing otherwise it expands to the root language label.

You can find the tracked dialects from a given root language using:

📌
``\TrackedDialectsFromLanguage`{〈root language label〉}`
This will expand to a comma-separated list of dialect labels if the root language label has been defined, otherwise it does nothing.

You can test if a language or dialect has a corresponding ISO code using:

📌
``\IfTrackedLanguageHasIsoCode`{〈code type〉}{〈label〉}{〈true〉}{〈false〉}`
where 〈code type〉 is the type of ISO code (for example, 639-1 for root languages or 3166-1 for regional dialects), and 〈label〉 is the language or dialect label. Note that the 639-3 may be set for the dialect rather than root language for sub-languages parsed using `\TrackLanguageTag`.

Alternatively, you can test if a particular ISO code has been defined using:

📌
``\IfTrackedIsoCode`{〈code type〉}{〈code〉}{〈true〉}{〈false〉}`
where 〈code type〉 is again the type of ISO code (for example, 639-1 or 3166-1), and 〈code〉 is the particular code (for example, en for ISO 639-1 or GB for ISO 3166-1).

You can fetch the language (or dialect) label associated with a given ISO code using:

📌
``\TrackedLanguageFromIsoCode`{〈code type〉}{〈code〉}`
This does nothing if the given 〈code〉 for the given ISO 〈code type〉 has not been defined, otherwise it expands a comma-separated list of language or dialect labels.

You can fetch the ISO code for a given code type using:

📌
``\TrackedIsoCodeFromLanguage`{〈code type〉}{〈label〉}`
where 〈label〉 is the language or dialect label and 〈code type〉 is the ISO code type (for example, 639-1 or 3166-1). Unlike `\TrackedLanguageFromIsoCode`, this command only expands to a single label rather than a comma-separated list.

The above commands do nothing in the event of an unknown code or code type, so if you accidentally get the wrong code type, you won’t get an error. If you’re unsure of the code type, you can use the following commands:

📌
``\TwoLetterIsoCountryCode``
This expands to 3166-1 and is used for the two-letter country codes.

📌
``\TwoLetterIsoLanguageCode``
This expands to 639-1 and is used for the two-letter root language codes.

📌
``\ThreeLetterIsoLanguageCode``
This expands to 639-2 and is used for the three-letter root language codes.

📌
``\ThreeLetterExtIsoLanguageCode``
This expands to 639-3. This code is only used for a root language if there’s no 639-1 or 639-2 code. It may also be used for a dialect if a sub-language part has been set in the language tag parsed by `\TrackLanguageTag`.

The `\Get…` commands below are designed to be expandable. If the supplied 〈dialect〉 is unrecognised they expand to empty. Remember that the dialect must first be identified as a tracked language for it to be recognised.

As from v1.3, the language tag for a given dialect can be obtained using:

📌
``\GetTrackedLanguageTag`{〈dialect〉}`
where 〈dialect〉 is the label identifying the dialect. Uses the und (undetermined) code for unknown languages.

As from v1.3, each tracked dialect may also have an associated modifier, which can be fetched using:

📌
``\GetTrackedDialectModifier`{〈dialect〉}`
where 〈dialect〉 is the label identifying the dialect. This value is typically obtained by parsing a POSIX locale identifier with `\TrackLocale` or `\TrackLangFromEnv` but may be set explicitly. (See §6 for setting this value. Likewise for the following commands.)

You can test if a dialect has an associated modifier using:

📌
``\IfHasTrackedDialectModifier`{〈dialect〉}{〈true〉}{〈false〉}`
If the dialect has an associated modifier this does 〈true〉 otherwise it does 〈false〉.

For example:

    🖹\documentclass[british,francais,american,canadian,canadien,dutch]{article}

    \usepackage{tracklang}

    \begin{document}
    Languages:
    \ForEachTrackedLanguage{\ThisLanguage}{\ThisLanguage\space
    (ISO \TwoLetterIsoLanguageCode:
    ``\TrackedIsoCodeFromLanguage
        {\TwoLetterIsoLanguageCode}{\ThisLanguage}''). }

    Dialects:
    \ForEachTrackedDialect{\ThisDialect}{\ThisDialect\space
    (\IfTrackedLanguageHasIsoCode
      {\TwoLetterIsoCountryCode}{\ThisDialect}%
     {ISO \TwoLetterIsoCountryCode:
      ``\TrackedIsoCodeFromLanguage
          {\TwoLetterIsoCountryCode}{\ThisDialect}''} {no specific region};
    root: \TrackedLanguageFromDialect{\ThisDialect}). }

    Language for ISO \TwoLetterIsoCountryCode\ ``GB'':
    \TrackedLanguageFromIsoCode
      {\TwoLetterIsoCountryCode}{GB}.

    Language for ISO \TwoLetterIsoCountryCode\ ``CA'':
    \TrackedLanguageFromIsoCode
      {\TwoLetterIsoCountryCode}{CA}.

    Country ISO \TwoLetterIsoCountryCode\ code for ``canadian'':
    \TrackedIsoCodeFromLanguage
      {\TwoLetterIsoCountryCode}{canadian}.
    \end{document}

This produces:
🖺
Languages: english (ISO 639-1: “en’’). french (ISO 639-1: “fr’’). dutch (ISO 639-1: “nl’’).

Dialects: american (ISO 3166-1: “US’’; root: english). british (ISO 3166-1: “GB’’; root: english). canadian (ISO 3166-1: “CA’’; root: english). canadien (ISO 3166-1: “CA’’; root: french). dutch (no specific region; root: dutch). francais (no specific region; root: french).

Language for ISO 3166-1 “GB’’: british.

Language for ISO 3166-1 “CA’’: canadian,canadien.

Country ISO 3166-1 code for “canadian’’: CA.

As from v1.3, each tracked dialect may also have an associated variant, which can be fetched using:

📌
``\GetTrackedDialectVariant`{〈dialect〉}`
where 〈dialect〉 is the label identifying the dialect. This value is typically obtained by parsing a language tag with `\TrackLanguageTag` but may be set explicitly.

You can test if a dialect has an associated variant using:

📌
``\IfHasTrackedDialectVariant`{〈dialect〉}{〈true〉}{〈false〉}`

As from v1.3, each tracked dialect may also have an associated script, which can be fetched using:

📌
``\GetTrackedDialectScript`{〈dialect〉}`
where 〈dialect〉 is the label identifying the dialect.

You can test if a dialect has an associated script using:

📌
``\IfHasTrackedDialectScript`{〈dialect〉}{〈true〉}{〈false〉}`
If the dialect has an associated script this does 〈true〉 otherwise it does 〈false〉. This information is provided for language packages that need to know what script is required, but there’s no guarantee that the script will actually be set in the document. Similarly for all the other attributes described here.

Note that the script should be a recognised four-letter ISO 15924 code, such as Latn or Cyrl. If a dialect doesn’t have an associated script then the default for the root language should be assumed. For example, Latn for English dialects or Cyrl for Russian dialects. The default script for known languages can be obtained using:

📌
``\TrackLangGetDefaultScript`{〈language〉}`
Most root languages have a default script, but there are a few without one as it may depend on region, politics or ideology.

There’s a convenient expandable command for testing the script:

📌
``\IfTrackedDialectIsScriptCs`{〈dialect〉}{〈cs〉}{〈true〉}{〈false〉}`
This tests if the given tracked dialect has an associated script and compares the value with the replacement text of 〈cs〉. If the dialect hasn’t been explicitly assigned a script, then test is performed against the default script for the root language.

The supplementary package tracklang-scripts provides some additional commands relating to writing systems, including commands in the form `\TrackLangScript〈Code〉` where 〈Code〉 is the ISO 15924 four-letter code. If the dialect doesn’t have an associated script, 〈false〉 is done. This package isn’t loaded automatically, so you’ll need to explicitly load it. The generic code is in tracklang-scripts.tex:

    🖹\input tracklang-scripts

There’s a convenient LaTeX wrapper tracklang-scripts.sty:

    🖹\usepackage{tracklang-scripts}

See §4 for further details of that package.

For example, the following defines a command to check if the given dialect should use a Latin script:

    🖹\input tracklang-scripts
    \def\islatin#1#2#3{%
      \IfTrackedDialectIsScriptCs{#1}{\TrackLangScriptLatn}{#2}{#3}%
    }

ℹ
Note that the script value doesn’t mean that the document is actually using that script. It means that this is the user’s desired script, but whether that script is actually set relies on the appropriate settings in the relevant language package (such as polyglossia’s script key).

As from v1.3, each tracked dialect may also have a sub-language identifier (for example, arevela), which can be fetched using:

📌
``\GetTrackedDialectSubLang`{〈dialect〉}`
where 〈dialect〉 is the label identifying the dialect.

You can test if a dialect has an associated sub-tag using:

📌
``\IfHasTrackedDialectSubLang`{〈dialect〉}{〈true〉}{〈false〉}`
If the dialect has an associated sub-tag this does 〈true〉 otherwise it does 〈false〉.

As from v1.3, each tracked dialect may also have additional information, which can be fetched using:

📌
``\GetTrackedDialectAdditional`{〈dialect〉}`
where 〈dialect〉 is the label identifying the dialect.

You can test if a dialect has additional information using:

📌
``\IfHasTrackedDialectAdditional`{〈dialect〉}{〈true〉}{〈false〉}`
If the dialect has additional information this does 〈true〉 otherwise it does 〈false〉.

Most packages that implement multilingual support have a set of language definition files for each supported language or dialect. It may be that only the root language is needed, if there are no variations between that language’s dialect (for the purposes of that package), or it may be that separate definition files are required for each dialect. However it can be awkward trying to map the requested dialect or language label to the file name. Should, say, the file containing the French code be called 〈prefix〉-french-〈suffix〉 or 〈prefix〉-frenchb-〈suffix〉 or 〈prefix〉-francais-〈suffix〉? Should, say, the file containing the British English code be called 〈prefix〉-british-〈suffix〉 or 〈prefix〉-UKenglish-〈suffix〉? If you want to modularise the language support for your package so that each language module has a different maintainer will the maintainers know what tag to use for their language?

To help with this, tracklang provides:

📌
``\IfTrackedLanguageFileExists`{〈dialect〉}{〈prefix〉}{〈suffix〉}{〈true code〉}{〈false code〉}`
This attempts to find the file called 〈prefix〉〈localeid〉〈suffix〉 where 〈localeid〉 is determined from 〈dialect〉 (see below). If the file is found then
📌
``\CurrentTrackedTag``
is set to 〈localeid〉 and 〈true code〉 is done, otherwise 〈false code〉 is done. If this command is empty, then the dialect hasn’t been detected. If the dialect has been detected, but no file can be found, then `\CurrentTrackedTag` is set to the final attempt at determining 〈localeid〉.

Sometimes the dialect label can cause a problem, especially if it happens to be identical to the root label. The solo region code check may also be problematic, so the following analoguous commands are also provided.

📌
``\IfTrackedLanguageFileExistsOmitDialectLabel`{〈dialect〉}{〈prefix〉}{〈suffix〉}{〈true code〉}{〈false code〉}`
As `\IfTrackedLanguageFileExists` but omits the test for the dialect label. Note that if the dialect label happens to be identical to the root language label, it will still be checked, but at the very end instead of near the start.

📌
``\IfTrackedLanguageFileExistsOmitOnlyRegion`{〈dialect〉}{〈prefix〉}{〈suffix〉}{〈true code〉}{〈false code〉}`
As `\IfTrackedLanguageFileExists` but omits the test for just the region code.

📌
``\IfTrackedLanguageFileExistsOmitDialectLabelOmitOnlyRegion`{〈dialect〉}{〈prefix〉}{〈suffix〉}{〈true code〉}{〈false code〉}`
Combination of the above two commands. As `\IfTrackedLanguageFileExists` but omits the tests for the dialect label and for just the region code.

There’s a convenient shortcut command new to version 1.3:

📌
``\TrackLangRequireDialect`[〈load code〉]{〈pkgname〉}{〈dialect〉}`
which uses `\IfTrackedLanguageFileExists` to input the resource file if found. The prefix is given by 〈pkgname〉`-` and the suffix is `.ldf`. A warning is issued if no resource file is found. Note that while it makes sense for 〈pkgname〉 to be the same as the base name of the package that uses these resource files, they don’t have to be the same. This command additionally defines:
📌
``\TrackLangRequireDialectPrefix``
to 〈pkgname〉, which allows the prefix to be picked up by resource file commands, such as `\TrackLangProvidesResource` and `\TrackLangRequireResource`. (See below.)

There are analogous commands

📌
``\TrackLangRequireDialectOmitDialectLabel`[〈load code〉]{〈pkgname〉}{〈dialect〉}`
As above, but uses `\IfTrackedLanguageFileExistsOmitDialectLabel`.

📌
``\TrackLangRequireDialectOmitDialectLabelOmitOnlyRegion`[〈load code〉]{〈pkgname〉}{〈dialect〉}`
As above, but uses `\IfTrackedLanguageFileExistsOmitDialectLabelOmitOnlyRegion`.

📌
``\TrackLangRequireDialectOmitOnlyRegion`[〈load code〉]{〈pkgname〉}{〈dialect〉}`
As above, but uses `\IfTrackedLanguageFileExistsOmitOnlyRegion`.

The optional argument 〈load code〉 is the code that actually inputs the required file. This defaults to

    🖹\TrackLangRequireResource{\CurrentTrackedTag}

The `\IfTrackedLanguageFileExists` command sets up the current tracked dialect with:

    \SetCurrentTrackedDialect{〈dialect〉}

which enables the following commands that may be used within 〈true code〉 or 〈false code〉:
📌
``\CurrentTrackedDialect``
Expands to the dialect label.

📌
``\CurrentTrackedLanguage``
If the dialect hasn’t been detected, this command will be empty, otherwise it will expand to the root language label (which may be the same as the dialect label).

📌
``\CurrentTrackedRegion``
If the dialect hasn’t been detected, this command will be empty. If the dialect has been assigned an ISO 3166-1 code, `\CurrentTrackedRegion` will expand to that code, otherwise it will be empty.

📌
``\CurrentTrackedIsoCode``
If the dialect hasn’t been detected, this command will be empty. Otherwise it may be empty or it may expand to the ISO 639-1 or ISO 639-2 or ISO 639-3 code.

📌
``\CurrentTrackedDialectModifier``
The dialect’s modifier or empty if not set. (This is set but not used in the set of possible 〈localeid〉 values.)

📌
``\CurrentTrackedDialectVariant``
The dialect’s variant or empty if not set.

📌
``\CurrentTrackedDialectSubLang``
The dialect’s sub-language code or empty if not set.

📌
``\CurrentTrackedDialectAdditional``
The dialect’s additional information or empty if not set.

📌
``\CurrentTrackedLanguageTag``
The dialect’s language tag. Take care not to confuse this with `\CurrentTrackedTag`.

📌
``\CurrentTrackedDialectScript``
The dialect’s script. If the dialect doesn’t have the script set, the default script for the language is used instead.

`\IfTrackedLanguageFileExists` behaves as follows:

- •If no dialect with the given label has been detected, the condition evaluates to false and `\CurrentTrackedTag` is empty.

- •If a dialect with the given label has been detected, then:
  - –For each possible 〈localeid〉 in an ordered set of tags determined by the dialect label (see below), the first file matching 〈prefix〉〈localeid〉〈suffix〉 that’s found on TeX’s path results in the condition evaluating to true and `\CurrentTrackedTag` is set to the current 〈localeid〉 in the set. The rest of the set of possible values of 〈localeid〉 is skipped.

  - –If no file matching 〈prefix〉〈localeid〉〈suffix〉 is found on TeX’s path, then the condition evaluates to false and `\CurrentTrackedTag` is set to the final 〈localeid〉 in the set (the language label).

The ordered set of possible values of 〈localeid〉 is determined from the given dialect.

ℹ
The ordering has changed in version 1.4, which now also includes the script and variant. This new ordering should typically make the more common combinations closer to the start of the search.
The possible values of 〈localeid〉 are listed below in the order of priority used by `\IfTrackedLanguageFileExists`. Note that the set may contain repetitions (for example, if the dialect label is the same as the root language label). If an item contains an element that hasn’t been set (such as the ISO 639-3 code or a sub-language 〈sublang〉 or variant) then that item is skipped.

1. 1.〈localeid〉 is just the value of `\CurrentTrackedLanguageTag`.

2. 2.〈localeid〉 is just the dialect label. This step is omitted with `\IfTrackedLanguageFileExistsOmitDialectLabel` and `\IfTrackedLanguageFileExistsOmitDialectLabelOmitOnlyRegion`.

3. 3.〈localeid〉 is 〈ISO 639-1〉`-`〈sublang〉`-`〈script〉`-`〈region〉.

4. 4.〈localeid〉 is 〈ISO 639-1〉`-`〈script〉`-`〈region〉.

5. 5.〈localeid〉 is 〈ISO 639-1〉`-`〈sublang〉`-`〈region〉 (if there’s no script or if the script is the default for the given language). 〈ISO 639-1〉`-`〈region〉 (if there’s no script or if the script is the default for the given language).

6. 6.〈localeid〉 is 〈ISO 639-1〉`-`〈sublang〉`-`〈script〉.

7. 7.〈localeid〉 is 〈ISO 639-1〉`-`〈script〉.

8. 8.〈localeid〉 is 〈ISO 639-1〉`-`〈sublang〉.

9. 9.〈localeid〉 is just 〈ISO 639-1〉.

10. 10.〈localeid〉 is 〈ISO 639-2〉`-`〈sublang〉`-`〈script〉`-`〈region〉.

11. 11.〈localeid〉 is 〈ISO 639-2〉`-`〈script〉`-`〈region〉.

12. 12.〈localeid〉 is 〈ISO 639-2〉`-`〈sublang〉`-``region` (if there’s no script or if the script is the default for the given language). 〈ISO 639-2〉`-`〈region〉 (if there’s no script or if the script is the default for the given language).

13. 13.〈localeid〉 is 〈ISO 639-2〉`-`〈sublang〉`-`〈script〉.

14. 14.〈localeid〉 is 〈ISO 639-2〉`-`〈script〉.

15. 15.〈localeid〉 is 〈ISO 639-2〉`-`〈sublang〉.
16. 16.〈localeid〉 is just 〈ISO 639-2〉.

17. 17.〈localeid〉 is 〈ISO 639-3〉`-`〈sublang〉`-`〈script〉`-`〈region〉.

18. 18.〈localeid〉 is 〈ISO 639-3〉`-`〈script〉`-`〈region〉.

19. 19.〈localeid〉 is 〈ISO 639-3〉`-`〈sublang〉`-`〈region〉 (if there’s no script or if the script is the default for the given language). 〈ISO 639-3〉`-`〈region〉 (if there’s no script or if the script is the default for the given language).

20. 20.〈localeid〉 is 〈ISO 639-3〉`-`〈sublang〉`-`〈script〉.

21. 21.〈localeid〉 is 〈ISO 639-3〉`-`〈script〉.

22. 22.〈localeid〉 is 〈ISO 639-3〉`-`〈sublang〉.

23. 23.〈localeid〉 is just 〈ISO 639-3〉.

24. 24.〈localeid〉 is just 〈region〉. This step is omitted with `\IfTrackedLanguageFileExistsOmitOnlyRegion` and `\IfTrackedLanguageFileExistsOmitDialectLabelOmitOnlyRegion`.

25. 25.〈localeid〉 is 〈ISO 639-1〉`-`〈sublang〉`-`〈variant〉 or 〈ISO 639-1〉`-`〈variant〉 if 〈sublang〉 is missing.

26. 26.〈localeid〉 is 〈ISO 639-2〉`-`〈sublang〉`-`〈variant〉 or 〈ISO 639-2〉`-`〈variant〉 if 〈sublang〉 is missing.

27. 27.〈localeid〉 is 〈ISO 639-3〉`-`〈sublang〉`-`〈variant〉 or 〈ISO 639-3〉`-`〈variant〉 if 〈sublang〉 is missing.

28. 28.〈localeid〉 is just the value of `\CurrentTrackedLanguage` (the root language label).

For example (pre v1.3):

    🖹\AnyTrackedLanguages
    {%
     \ForEachTrackedDialect{\ThisDialect}%
     {%
      % try to load the language file for this dialect
      \IfTrackedLanguageFileExists{\ThisDialect}%
      {mypackage-}% file prefix
      {.ldf}% file suffix
      {\input mypackage-\CurrentTrackedTag.ldf}% file found
      {% file not found
        \PackageWarning{mypackage}
          {No support for language `\ThisDialect'}%
      }%
     }%
    }
    {% no languages detected so use defaults
    }

With version 1.3 onwards, this can be written more concisely as:

    🖹\AnyTrackedLanguages
    {%
     \ForEachTrackedDialect{\ThisDialect}%
     {%
      % try to load the language file for this dialect
      \TrackLangRequireDialect{mypackage}{\ThisDialect}%
     }%
    }
    {% no languages detected so use defaults
    }

which additionally enables the tracklang version 1.3 commands described below, such as `\TrackLangRequireResource`.

If, for example, `\ThisDialect` is british, then the file search will be in the order:

1. 1.mypackage-en-GB.ldf (language tag)
2. 2.mypackage-british.ldf (dialect label)

3. 3.mypackage-en-Latn-GB.ldf (639-1 language code, script, region)
4. 4.mypackage-en-GB.ldf (639-1 language code, region)
5. 5.mypackage-en-Latn.ldf (639-1 language code, script)
6. 6.mypackage-en.ldf (639-1 language code)

7. 7.mypackage-eng-Latn-GB.ldf (639-2 language code, script, region)
8. 8.mypackage-eng-GB.ldf (639-2 language code, region)
9. 9.mypackage-eng-Latn.ldf (639-2 language code, script)
10. 10.mypackage-eng.ldf (639-2 language code)

11. 11.mypackage-GB.ldf (region)
12. 12.mypackage-english.ldf (language label)

If, for example, `\ThisDialect` is naustrian, then the file search will be in the order:

1. 1.mypackage-de-AT-1996.ldf (language tag)
2. 2.mypackage-naustrian.ldf (dialect label)

3. 3.mypackage-de-Latn-AT.ldf (639-1 language code, script, region)
4. 4.mypackage-de-AT.ldf (639-1 language code, region)
5. 5.mypackage-de-Latn.ldf (639-1 language code, script)
6. 6.mypackage-de.ldf (639-1 language code)

7. 7.mypackage-deu-Latn-AT.ldf (639-2 language code, script, region)
8. 8.mypackage-deu-AT.ldf (639-2 language code, region)
9. 9.mypackage-deu-Latn.ldf (639-2 language code, script)
10. 10.mypackage-deu.ldf (639-2 language code)

11. 11.mypackage-AT.ldf (region)

12. 12.mypackage-de-1996.ldf (639-1 language code, variant)
13. 13.mypackage-deu-1996.ldf (639-2 language code, variant)

14. 14.mypackage-german.ldf (language label)

If, for example, `\ThisDialect` is francais, then the file search will be in the order:

1. 1.mypackage-fr.ldf (language tag)
2. 2.mypackage-francais.ldf (dialect label)
3. 3.mypackage-fr-Latn.ldf (639-1 language code, script)
4. 4.mypackage-fr.ldf (639-1 language code)
5. 5.mypackage-fra-Latn.ldf (639-2 language code, script)
6. 6.mypackage-fra.ldf (639-2 language code)
7. 7.mypackage-french.ldf (language)

This is because the predefined francais option has no region assigned to it. Be careful if the dialect label is the actual root language. For example, if `\ThisDialect` is french, then the file search will be in the order:

1. 1.mypackage-fr.ldf (language tag)
2. 2.mypackage-french.ldf (dialect label)
3. 3.mypackage-fr-Latn.ldf (639-1 language code, script)
4. 4.mypackage-fr.ldf (639-1 language code)
5. 5.mypackage-fra-Latn.ldf (639-2 language code, script)
6. 6.mypackage-fra.ldf (639-2 language code)
7. 7.mypackage-french.ldf (language)

Note that the last try will always fail in this case since if the file exists, it will be found on the second try.

If the dialect label is identical to the root language label then it means that all associated information is the default for that language. For example, in the above case of french, the script is Latn and the region is unspecified. The root language label can therefore be used as the fallback in the event of no other match but for the specific case where the dialect is identical to the root language then all unnecessary file name checks can be skipped.

If you’re only providing support for the root languages (pre v1.3):

    🖹\AnyTrackedLanguages
    {%
     \ForEachTrackedLanguage{\ThisLanguage}%
     {% try to load the language file for this root language
       \IfTrackedLanguageFileExists{\ThisLanguage}%
       {mypackage-}% file prefix
       {.ldf}% file suffix
       {\input mypackage-\CurrentTrackedTag.ldf}% file found
       {% file not found
         \PackageWarning{mypackage}{No support for language
          `\ThisLanguage'}%
       }%
     }%
    }
    {% no languages detected so use defaults
    }

With version 1.3 onwards, this can be written more concisely as:

    🖹\AnyTrackedLanguages
    {%
     \ForEachTrackedLanguage{\ThisLanguage}%
     {% try to load the language file for this root language
       \TrackLangRequireDialect{mypackage}{\ThisLanguage}%
     }%
    }
    {% no languages detected so use defaults
    }

which additionally enables the commands described below. Note that in this case, if more than one dialect for the same language has been tracked, only the hooks for the last dialect for that language will be adjusted, so it’s usually best to iterate over the dialects.

The following `\TrackLang…Resource…` commands may only be used in resource files that are loaded using `\TrackLangRequireDialect`. An error will occur if the file is input through some other method.

Within the resource file 〈pkgname〉-〈localeid〉.ldf, you can identify the file using (new to version 1.3):

📌
``\TrackLangProvidesResource`{〈tag〉}[〈version info〉]`
where 〈tag〉 is the locale identifier.

If `\ProvidesFile` is defined (through the LaTeX kernel) this is used, otherwise a simplified generic alternative is used that’s suitable for other TeX formats.

The resource file can load another resource file 〈pkgname〉-〈tag〉.ldf, using (new to version 1.3):

📌
``\TrackLangRequireResource`{〈tag〉}`
For example, the dialect file foo-en-GB.ldf might need to load the root language resource file foo-english.ldf:

    🖹% (In file foo-en-GB.ldf)
    % Declare this regional file:
    \TrackLangProvidesResource{en-GB}
    % load root language file foo-english.ldf:
    \TrackLangRequireResource{english}

If foo-english.ldf is also identified with `\TrackLangProvidesResource`, this will ensure that it’s only loaded once.

It may be that you want to load a file depending on the input encoding. The inputenc package defines `\inputencodingname`, but this is only used with pdfLaTeX. To avoid repeated tests to determine whether or not `\inputencodingname` has been defined, you can use:

📌
``\TrackLangEncodingName``
This will expand to `utf8` if `\inputencodingname` hasn’t been defined (or has been set to `\relax`), otherwise it will expand to `\inputencodingname`. For example:

    🖹\InputIfFileExists{foo-\TrackLangEncodingName.ldf}
    {% support available for the document encoding
    }
    {% no support for the document encoding
    }

If you require the resource file and want to perform 〈code1〉 if it’s loaded at this point or 〈code2〉 if it’s already been loaded then you can use:

📌
``\TrackLangRequireResourceOrDo`{〈tag〉}{〈code1〉}{〈code2〉}`

If you want to load a resource file if it exists (without an error if it doesn’t exist), then you can use

📌
``\TrackLangRequestResource`{〈tag〉}{〈not found code〉}`
If the file doesn’t exist, 〈not found code〉 is done.

ℹ
Note that these `\…Resource…` commands are only permitted within the resource files. They are internally enabled through `\TrackLangRequireDialect`.

The above restriction on the resource files loaded through `\TrackLangRequireDialect`, and the fact that it internally uses `\IfTrackedLanguageFileExists`, means that commands like `\CurrentTrackedLanguage` or `\CurrentTrackedDialect` may be used in those files. This means that the name of the captions hook can be obtained through them. (Remember that the file foo-en-GB.ldf might have been loaded with, say, the british dialect or with the synonymous UKenglish dialect or with a dialect label that doesn’t have a corresponding caption hook, such as enGBLatn.)

The polyglossia package has language caption hooks in the form `\captions〈language〉` (where 〈language〉 is the root language label) whereas babel has dialect captions hooks in the form `\captions〈dialect〉` (where 〈dialect〉 is the dialect label). This leads to a rather cumbersome set of conditionals:

    \ifcsundef{captions\CurrentTrackedLanguage}
    {%
      \ifcsundef{captions\CurrentTrackedDialect}%
      {}%
      {%
        \csgappto{captions\CurrentTrackedDialect}{%
          % code to append to hook
        }%
      }%
    }%
    {%
      \csgappto{captions\CurrentTrackedLanguage}{%
        % code to append to hook
      }%
    }
    % do code now to initialise

Note that the above has been simplified through the use of etoolbox commands, which isn’t suitable for generic use. It also doesn’t query the mapping from tracklang’s dialect label to the closest matching babel dialect label.

Instead, tracklang provides a command to perform this set of conditionals using generic code:

📌
``\TrackLangAddToHook`{〈code〉}{〈type〉}`
where 〈code〉 is the code to append to the 〈type〉 hook. This always performs 〈code〉 after testing for the hook in case the hook is undefined or has already been called (for example, ngerman uses `\captionsngerman` when the package is loaded, not at the start of the document).

Note that this command is enabled through `\TrackLangRequireDialect` so should only be used inside resource files.

Since captions is a commonly used hook type, there’s a shortcut command provided:

📌
``\TrackLangAddToCaptions`{〈code〉}`
This is equivalent to

    \TrackLangAddToHook{〈code〉}{captions}

There may be some hooks, such as `\date〈dialect〉`, that need redefining rather than appending to, so there’s an analogous command:

📌
``\TrackLangRedefHook`{〈code〉}{〈type〉}`
which will redefined the hook to do 〈code〉.

Note that no expansion is performed on 〈code〉 when appending or redefining a hook.

[top]

## 5.1. Examples[link]

The examples in this section illustrate the above commands.

[top]

### 5.1.1. animals.sty[link]

This example is for a trivial package called animals.sty that defines three textual commands: `\catname`, `\dogname` and `\ladybirdname`. The default values are: “cat”, “dog” and “bishy-barney-bee”.1 The supported languages are defined in files animals-〈localeid〉.ldf.

Here’s the code for animals.sty:

    🖹% Example package animals.sty
    \NeedsTeXFormat{LaTeX2e}
    \ProvidesPackage{animals}

    \RequirePackage{tracklang}[2019/11/30]% v1.4

    % Any undeclared options are language settings:

    \DeclareOption*{%
     \TrackIfKnownLanguage{\CurrentOption}%
     {% successful
      \PackageInfo{animals}{Tracking language `\CurrentOption'}%
     }%
     {% failed
       \PackageError{animals}%
       {Unknown language specification `\CurrentOption'}%
       {You need to supply either a known dialect label
        or a valid language tag}%
     }%
    }

    \ProcessOptions

    % Default definitions
    \newcommand\catname{cat}
    \newcommand\dogname{dog}
    \newcommand\ladybirdname{bishy-barney-bee}

    \AnyTrackedLanguages
    {%
      \ForEachTrackedDialect{\this@dialect}{%
        \TrackLangRequireDialect{animals}{\this@dialect}%
      }%
    }
    {% no tracked languages, default already set up
    }

    \endinput

Here’s a Plain TeX version that picks up the language from the locale environment variable:

    🖹\input tracklang

    \TrackLangFromEnv

    % Default definitions
    \def\catname{cat}
    \def\dogname{dog}
    \def\ladybirdname{bishy-barney-bee}

    \AnyTrackedLanguages
    {%
      \ForEachTrackedDialect{\thisdialect}{%
        \TrackLangRequireDialect{animals}{\thisdialect}%
      }%
    }
    {% no tracked languages, default already set up
    }

In the event that a user or supplementary package for some reason wants to load a resource file for a language that hasn’t been tracked, it might be worth providing a command for this purpose:

    🖹\newcommand*{\RequireAnimalsDialect}[1]{%
      \TrackLangRequireDialect{animals}{#1}%
    }

The loop can then be changed to:

    🖹\ForEachTrackedDialect{\this@dialect}{%
      \RequireAnimalsDialect\this@dialect
    }%

The animals-english.ldf file valid for both the Plain TeX and LaTeX formats contains:

    🖹\TrackLangProvidesResource{english}

    \def\englishanimals{%
      \def\catname{cat}%
      \def\dogname{dog}%
      \def\ladybirdname{bishy-barney-bee}%
    }

    \TrackLangAddToCaptions{\englishanimals}

The animals-en-GB.ldf file contains:

    🖹\TrackLangProvidesResource{en-GB}
    \TrackLangRequireResource{english}

    \def\enGBanimals{%
      \englishanimals
      \def\ladybirdname{ladybird}%
    }
    \TrackLangAddToCaptions{\enGBanimals}

The animals-en-US.ldf file contains:

    🖹\TrackLangProvidesResource{en-US}
    \TrackLangRequireResource{english}

    \def\enUSanimals{%
      \englishanimals
      \def\ladybirdname{ladybug}%
    }
    \TrackLangAddToCaptions{\enUSanimals}

Here’s a German version in the file animals-german.ldf:

    🖹\TrackLangProvidesResource{german}

    \def\germananimals{%
      \def\catname{Katze}%
      \def\dogname{Hund}%
      \def\ladybirdname{Marienk\"afer}%
    }

    \TrackLangAddToCaptions{\germananimals}

This means that if babel or polyglossia are loaded, the redefinitions are automatically performed whenever the language is changed, but if there’s no caption mechanism the user can switch the fixed names using the `\…animals` commands.

Here’s an example LaTeX document that doesn’t have any caption hooks:

    🖹\documentclass[english,german]{article}

    \usepackage{animals}

    \begin{document}
    \englishanimals

    \catname.
    \dogname.
    \ladybirdname.

    \germananimals

    \catname.
    \dogname.
    \ladybirdname.
    \end{document}

Here’s a babel example document:

    🖹\documentclass[american,german,british]{article}

    \usepackage{babel}
    \usepackage{animals}

    \begin{document}
    \selectlanguage{american}

    \catname.
    \dogname.
    \ladybirdname.

    \selectlanguage{german}

    \catname.
    \dogname.
    \ladybirdname.

    \selectlanguage{british}

    \catname.
    \dogname.
    \ladybirdname.
    \end{document}

There is some redundancy with the above resource files. Consider the babel example above. The american dialect is the first option, so in that case animals-en-US.ldf is loaded followed by animals-english.ldf. This means that the `\captionsamerican` hook now includes

    🖹\englishanimals
    \enUSanimals

Since `\enUSanimals` includes `\englishanimals`, there is redundant code. However, when the british dialect is processed, this loads the file animals-en-GB.ldf but not the file animals-english.ldf (since it’s already been loaded). This means that `\captionsbritish` contains `\enGBanimals` but not `\englishanimals`.

If this redundancy is an issue (for example, there are so many redefinitions needed that it significantly slows the document build process), then it can be addressed with the following modifications. The animals-en-GB.ldf file is now:

    🖹\TrackLangProvidesResource{en-GB}

    \def\enGBanimals{%
      \englishanimals
      \def\ladybirdname{ladybird}%
    }

    \TrackLangRequireResourceOrDo{english}%
    {
      \TrackLangAddToCaptions{%
        \def\ladybirdname{ladybird}%
      }%
    }
    {
      \TrackLangAddToCaptions{\enGBanimals}
    }

The animals-en-US.ldf file is now:

    🖹\TrackLangProvidesResource{en-US}

    \providecommand*{\enUSanimals}{%
      \englishanimals
      \renewcommand*{\ladybirdname}{ladybug}%
    }

    \TrackLangRequireResourceOrDo{english}
    {
      \TrackLangAddToCaptions{%
        \renewcommand*{\ladybirdname}{ladybird}%
      }%
    }
    {
      \TrackLangAddToCaptions{\enUSanimals}
    }

This means that the document that has the dialects listed in the order american, british now has

    🖹\englishanimals
    \def\ladybirdname{ladybird}

in the `\captionsbritish` hook and just `\enUSanimals` in the `\captionsamerican` hook, which has removed most of the redundancy.

Note that polyglossia has a `\captionsenglish` hook but not `\captionsamerican` or `\captionsbritish`, so this code doesn’t allow for switching between variants of the same language with polyglossia.

[top]

### 5.1.2. regions.sty[link]

Earlier, I mentioned the search order for `\IfTrackedLanguageFileExists` where if, for example, the dialect is british, the file search (v1.4+) will be:

1. 1.mypackage-en-GB.ldf (language tag)
2. 2.mypackage-british.ldf (dialect label)

3. 3.mypackage-en-Latn-GB.ldf (639-1 language code, script, region)
4. 4.mypackage-en-GB.ldf (639-1 language code, region)
5. 5.mypackage-en-Latn.ldf (639-1 language code, script)
6. 6.mypackage-en.ldf (639-1 language code)

7. 7.mypackage-eng-Latn-GB.ldf (639-2 language code, script, region)
8. 8.mypackage-eng-GB.ldf (639-2 language code, region)
9. 9.mypackage-eng-Latn.ldf (639-2 language code, script)
10. 10.mypackage-eng.ldf (639-2 language code)

11. 11.mypackage-GB.ldf (region)
12. 12.mypackage-english.ldf (language label)

You may have wondered why mypackage-GB.ldf is included in the search given that some countries have multiple official languages, which means that the country code on its own may not indicate the language.

The reason for including just the country code as the 〈localeid〉 in the file search is to allow for region rather than language dependent settings. For example, suppose I want to write a package that needs to know whether to use imperial or metric measurements in the document, but I also want to provide multilingual support. The language alone won’t tell me whether to use imperial or metric (for example, the US uses imperial and the UK uses metric for most product attributes). I could provide ldf files for every language and region combination, but this would result in a lot redundancy.

`\TrackLangRequireDialect` has an optional argument for adjusting the way the resource files are loaded. Suppose I have regions-〈localeid〉.ldf resource files, then

    🖹\TrackLangRequireDialect{regions}{\this@dialect}

loads the resource file for the dialect given by `\this@dialect` using:

    \TrackLangRequireResource{\CurrentTrackedTag}

I can use the optional argument to also load the resource file for the root language as well:

    🖹% custom file loader for regions.sty
    \newcommand*{\RequireRegionsDialect}[1]{%
     \TrackLangRequireDialect
      [\TrackLangRequireResource{\CurrentTrackedTag}%
       \TrackLangRequireResource
         {\CurrentTrackedLanguage}%
      ]%
      {regions}{#1}%
    }

Now the dialect british can load both regions-GB.ldf and regions-english.ldf.

The example package (regions.sty) below illustrates this.

    🖹% Example package regions.sty
    \NeedsTeXFormat{LaTeX2e}
    \ProvidesPackage{regions}

    \RequirePackage{tracklang}[2016/10/07]% v1.3+

    \DeclareOption*{\TrackLanguageTag{\CurrentOption}}
    \ProcessOptions

    \newcommand*{\weightunit}{kg}
    \newcommand*{\lengthunit}{mm}
    \newcommand*{\currencyunit}{EUR}

    \newcommand*{\unitname}{units}

    \newcommand*{\RequireRegionsDialect}[1]{%
     \TrackLangRequireDialect
      [\TrackLangRequireResource{\CurrentTrackedTag}%
       \TrackLangRequireResource
         {\CurrentTrackedLanguage}%
      ]%
      {regions}{#1}%
    }

    \AnyTrackedLanguages
    {%
     \ForEachTrackedDialect{\this@dialect}{%
       \RequireRegionsDialect\this@dialect
     }%
    }
    {% no tracked languages, default already set up
    }

    \endinput

There are separate ldf files for region and language. First are the regions.

- •regions-BE.ldf (Belgium):

      🖹\TrackLangProvidesResource{BE}

      \providecommand*{\BEunits}{%
        \renewcommand*{\weightunit}{kg}%
        \renewcommand*{\lengthunit}{mm}%
        \renewcommand*{\currencyunit}{EUR}%
      }

      \TrackLangAddToCaptions{\BEunits}

- •regions-CA.ldf (Canada):

      🖹\TrackLangProvidesResource{CA}

      \providecommand*{\CAunits}{%
        \renewcommand*{\weightunit}{kg}%
        \renewcommand*{\lengthunit}{mm}%
        \renewcommand*{\currencyunit}{CAD}%
      }

      \TrackLangAddToCaptions{\CAunits}

- •regions-GB.ldf (Great Britain):

      🖹\TrackLangProvidesResource{GB}

      \providecommand*{\GBunits}{%
        \renewcommand*{\weightunit}{kg}%
        \renewcommand*{\lengthunit}{mm}%
        \renewcommand*{\currencyunit}{GBP}%
      }

      \TrackLangAddToCaptions{\GBunits}

- •regions-US.ldf (USA):

      🖹\TrackLangProvidesResource{US}

      \providecommand*{\USunits}{%
        \renewcommand*{\weightunit}{lb}%
        \renewcommand*{\lengthunit}{in}%
        \renewcommand*{\currencyunit}{USD}%
      }

      \TrackLangAddToCaptions{\USunits}

Now the language files:

- •regions-dutch.ldf:

      🖹\TrackLangProvidesResource{dutch}

      \providecommand*{\dutchnames}{%
        \renewcommand*{\unitname}{meeteenheden}%
      }

      \TrackLangAddToCaptions{\dutchnames}

- •regions-english.ldf:

      🖹\TrackLangProvidesResource{english}

      \providecommand*{\englishnames}{%
        \renewcommand*{\unitname}{units}%
      }

      \TrackLangAddToCaptions{\englishnames}

- •regions-french.ldf:

      🖹\TrackLangProvidesResource{french}

      \providecommand*{\frenchnames}{%
        \renewcommand*{\unitname}{unit\'es}%
      }

      \TrackLangAddToCaptions{\frenchnames}

- •regions-german.ldf:

      🖹\TrackLangProvidesResource{french}

      \providecommand*{\germannames}{%
        \renewcommand*{\unitname}{Ma\ss einheiten}%
      }

      \TrackLangAddToCaptions{\germannames}

Here’s an example document that uses this package:

    🖹\documentclass[canadien]{article}

    \usepackage{regions}

    \begin{document}

    \unitname: \weightunit, \lengthunit, \currencyunit.

    \end{document}

This works because the 〈localeid〉 search looks for the country code before the root language label. However, this will fail if the dialect label is the same as a root language label that has an associated territory, marked with † in Table 1.2, as then it will be picked up before the country code.

In the above example, regions-CA.ldf is matched rather than regions-french.ldf, so regions-CA.ldf is loaded by

    \TrackLangRequireResource{\CurrentTrackedTag}

After this, the language file regions-french.ldf is then loaded:

    \TrackLangRequireResource{\CurrentTrackedLanguage}

This assumes that there’s a country code ldf file available. This example needs a little modification to use default units in case the region is missing:

    🖹% Modified example package regions.sty
    \NeedsTeXFormat{LaTeX2e}
    \ProvidesPackage{regions}

    % Pass all options to tracklang.sty:
    \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{tracklang}}
    \ProcessOptions

    \RequirePackage{tracklang}

    \newcommand*{\weightunit}{kg}
    \newcommand*{\lengthunit}{mm}
    \newcommand*{\currencyunit}{EUR}

    \newcommand*{\unitname}{units}

    \newcommand*{\defaultunits}{%
      \renewcommand*{\weightunit}{kg}%
      \renewcommand*{\lengthunit}{mm}%
      \renewcommand*{\currencyunit}{EUR}%
    }

    \newcommand*{\RequireRegionsDialect}[1]{%
     \TrackLangRequireDialect
      [\TrackLangRequireResource{\CurrentTrackedTag}%
        \ifx\CurrentTrackedTag\CurrentTrackedLanguage
          \TrackLangAddToCaptions{\defaultunits}%
        \else
          \TrackLangRequireResource
            {\CurrentTrackedLanguage}%
        \fi
      ]%
      {regions}{#1}%
    }

    \AnyTrackedLanguages
    {%
      \ForEachTrackedDialect{\this@dialect}%
        \RequireRegionsDialect\this@dialect
      %
    }
    {% no tracked languages, default already set up
    }

    \endinput

Note that we still have a problem for dialect labels that are identical to root language labels with an associated territory (such as manx). This case can be checked with the following adjustment:

    🖹\newcommand*{\RequireRegionsDialect}[1]{%
     \TrackLangRequireDialect
     [\TrackLangRequireResource{\CurrentTrackedTag}%
      \ifx\CurrentTrackedTag\CurrentTrackedLanguage
        \ifx\CurrentTrackedRegion\empty
          \TrackLangAddToCaptions{\defaultunits}%
        \else
          \TrackLangRequireResource
            {\CurrentTrackedRegion}%
        \fi
      \else
        \TrackLangRequireResource
           {\CurrentTrackedLanguage}%
      \fi
     ]%
     {regions}{#1}%
    }

In the case where both the dialect and root language label are manx with the resource files regions-manx.ldf and regions-IM.ldf, then `\CurrentTrackedTag` will be manx (the dialect label) so regions-manx.ldf will be loaded with:

    \TrackLangRequireResource{\CurrentTrackedTag}

In this case `\CurrentTrackedRegion` is `IM` (that is, it’s not empty) so then regions-IM.ldf will be loaded with:

    \TrackLangRequireResource{\CurrentTrackedRegion}

Here’s another document that sets up dialects with tracklang labels that aren’t recognised by babel. This means that there’s no corresponding `\captions〈dialect〉` hook for either the dialect label or the root language label, so mappings need to be defined from the tracklang dialect label to the matching babel dialect label.

    🖹\documentclass{article}

    \usepackage{tracklang}

    \TrackLanguageTag{de-US-1996}
    \SetTrackedDialectLabelMap
      {\TrackLangLastTrackedDialect}{ngerman}

    \TrackLanguageTag{en-MT}
    \SetTrackedDialectLabelMap
      {\TrackLangLastTrackedDialect}{UKenglish}

    \usepackage[main=ngerman,UKenglish]{babel}
    \usepackage{regions}

    \begin{document}
    \selectlanguage{ngerman}

    \unitname: \weightunit, \lengthunit, \currencyunit.

    \selectlanguage{UKenglish}

    \unitname: \weightunit, \lengthunit, \currencyunit.

    \end{document}

This produces:
🖺
Maßeinheiten: lb, in, USD.

units: kg, mm, EUR.

Compare this with:

    🖹\documentclass{article}

    \usepackage[main=ngerman,UKenglish]{babel}
    \usepackage{regions}

    \begin{document}
    \selectlanguage{ngerman}

    \unitname: \weightunit, \lengthunit, \currencyunit.

    \selectlanguage{UKenglish}

    \unitname: \weightunit, \lengthunit, \currencyunit.

    \end{document}

which produces:
🖺
Maßeinheiten: kg, mm, EUR.

units: kg, mm, GBP.

Note that these mappings aren’t needed if babel is loaded with the root language labels instead. For example:

    🖹\documentclass{article}

    \usepackage{tracklang}

    \TrackLanguageTag{de-US-1996}
    \SetTrackedDialectLabelMap
     {\TrackLangLastTrackedDialect}{ngerman}

    \TrackLanguageTag{en-MT}

    \usepackage[main=ngerman,english]{babel}
    \usepackage{regions}

    \begin{document}
    \selectlanguage{ngerman}

    \unitname: \weightunit, \lengthunit, \currencyunit.

    \selectlanguage{english}

    \unitname: \weightunit, \lengthunit, \currencyunit.

    \end{document}

No mapping is required for the en-MT locale as it can pick up `\captionsenglish` when `\TrackLangAddToHook` (used by `\TrackLangAddToCaptions`) queries the root language label after failing to find the language hook from the dialect label.

Some of the predefined tracklang dialects come with a mapping to the closest matching babel dialect label. For example, the option ngermanDE listed in Table 1.3 automatically provides a mapping to ngerman. Since a tracklang dialect label can only map to one babel label, this can be problematic for synonymous labels such as british/UKenglish or american/USenglish. The default mappings used by tracklang are shown in Table 1.3.

[top]

# 6. Adding Support for Language Tracking[link]

If you are writing a package that sets up the document languages (rather than a package that provides multilingual support if the user has already loaded a language package) then you can load tracklang and use the commands below to help other packages track your provided languages. (See also: Integrating tracklang.tex into Language Packages.)

The tracklang package can be loaded using

    🖹\input tracklang

or (LaTeX only)

    🖹\RequirePackage{tracklang}

When using LaTeX, there’s a difference between the two. The first case prevents tracklang from picking up the document class options but skips the check for known language packages. This check is redundant since your package is the language package, so you need to decide whether or not to allow the user to set up the localisation information through the document class options.

There’s a hook that, if defined, is performed by tracklang.sty after the package options have been loaded but before known language packages are checked:

📌
``\@tracklang@prelangpkgcheck@hook``

If you prefer `\RequirePackage` over `\input` but you want to make tracklang.sty skip the check for known language packages then (as from v1.3.8) define the pre-language package check hook as follows:

    🖹\providecommand\@tracklang@prelangpkgcheck@hook{\endinput}
    \RequirePackage{tracklang}[2019/10/06]% v1.3.8+

This will still pick up languages supplied through the document class options.

If you just use `\input`, there’s a test at the start of tracklang.tex to determine if it’s already been loaded, so you don’t need to worry if the document has already input it.

To integrate tracklang into your language package, you need to consider the following steps:

1. 1.Does tracklang define your supported ISO 15924 language scripts in the tracklang-scripts.tex file?

   If yes, then skip this step. Otherwise create a file with the relevant `\TrackLangScriptMap` command for each unknown script and identify this new file with `\TrackLangAddExtraScriptFile` (see §6.3). This usually won’t be necessary unless you have a custom script or a child script (a script that’s a sub-category of another script).

2. 2.Does tracklang recognise the root language?

   If yes, then skip this step.

   If your package is setting up a language that tracklang doesn’t recognise then you will need to define the root language using `\TrackLangNewLanguage` (see §6.5).

   This usually won’t be the case as tracklang should support all languages that have an official ISO 639-1 alpha-2 code.

   If you simply have a different label from tracklang identifying the root language, then you can just set up your label as a dialect using `\TrackLangProvidePredefinedDialect`.

3. 3.Does tracklang define the relevant ISO 3166-1 region codes in the tracklang-region-codes.tex file?

   If yes, then skip this step. Otherwise create a file with the relevant `\TrackLangRegionMap` command for each new region and identify this new file with `\TrackLangAddExtraRegionFile` (see §6.4). This usually won’t be necessary as tracklang should recognise all countries that have an alpha-2 region code, but you may require it if you need a broader region, such as EU.

4. 4.Do you want to define some convenient dialect labels that can be used with `\TrackPredefinedDialect`?

   If no, then skip this step. Otherwise you can use `\TrackLangProvidePredefinedLanguage` for root languages and `\TrackLangProvidePredefinedDialect` for dialects with additional information, such as a region, sub-language or script (see §6.6).

5. 5.In your language initialisation code, add the tracklang code to track the particular dialect (for example, use `\TrackPredefinedDialect` for recognised dialect labels or use the `\AddTracked〈Xxx〉` set of commands). See §6.1.

6. 6.In your language selection code (such as `\selectlanguage`), add `\SetCurrentTrackedDialect`{〈label〉} to allow the document author to easily query the current localisation settings (such as the region). See §6.2.

[top]

## 6.1. Initialising a New Language or Dialect[link]

When the user requests a particular dialect through your language package, you can notify tracklang of this choice using

    \TrackPredefinedDialect{〈dialect label〉}

provided the dialect label is recognised by tracklang (all those listed in Tables 1.1, 1.2 & 1.3).

If there’s no matching dialect predefined by tracklang, you can just use `\TrackLocale` or `\TrackLanguageTag` (described in §3) with the appropriate ISO codes if you’re not providing caption hooks.

If you are providing a captions hook mechanism in the form `\captions〈dialect〉`, then if 〈dialect〉 doesn’t match the corresponding tracklang dialect label, you can provide a mapping using `\SetTrackedDialectLabelMap`, described below.

[top]

## 6.2. Switching Language or Dialect[link]

When the document author switches to a different language or dialect, the current localisation information can be set with:

📌
``\SetCurrentTrackedDialect`{〈dialect〉}`
where 〈dialect〉 may the tracklang dialect label, or the mapped label previously set through `\SetTrackedDialectLabelMap`, described below, or the language label (in which case the last dialect to be tracked with that root language will be assumed).

This will make the following commands available which may be of use to other packages:

- •`\CurrentTrackedDialect` The dialect label recognised by tracklang (which may not be the same as 〈dialect〉).

- •`\CurrentTrackedLanguage` The root language label used by tracklang.

- •`\CurrentTrackedDialectModifier` The dialect modifier.

- •`\CurrentTrackedDialectVariant` The dialect variant.

- •`\CurrentTrackedDialectScript` The dialect script. Note that if tracklang-scripts is also loaded, this allows the script direction to be accessed using

      🖹\TrackLangScriptAlphaToDir
       {\CurrentTrackedDialectScript}

  See §4 for further details.

- •`\CurrentTrackedDialectSubLang` The dialect sub-language code.

- •`\GetTrackedDialectAdditional` The dialect’s additional information.

- •`\CurrentTrackedIsoCode` The dialect’s root language ISO code. (The first found in the sequence 639-1, 639-2, 639-3.)

- •`\CurrentTrackedRegion` The dialect’s ISO 3166-1 region code.

- •`\CurrentTrackedLanguageTag` The dialect’s language tag.

(Without this automated use of `\SetCurrentTrackedDialect`, the same information can be picked up using commands like `\GetTrackedDialectScript`, but that’s less convenient, especially if `\languagename` needs to be converted to 〈dialect〉. See the accompanying sample file sample-setlang.tex for an example.)

[top]

## 6.3. Defining New Scripts[link]

The tracklang-scripts.tex file isn’t automatically loaded, but if it is then, as from v1.4, it contains a hook at the end of the file that can be used to load additional files that define supplementary scripts. This entails creating a file called, say, mypackage-scripts.tex that contains:

    \TrackLangScriptMap{〈alpha code〉}{〈numeric code〉}{〈name〉}{〈direction〉}{〈parent script〉}

The first argument 〈alpha code〉 is the four-letter ISO 15924 code (such as Latn), the second argument is the numeric code (such as 215), the third argument 〈name〉 is the name of the script (such as Latin), the fourth argument is the direction (such as LR for left-to-right) and the final argument is the parent script (leave blank if there’s no parent). Note that this command will override any previous mapping for those codes. No check is performed to determine if they have already been defined.

The supplementary file should be identified with:

    \TrackLangAddExtraScriptFile{〈filename〉}

Additional information can be found in §4.

[top]

## 6.4. Defining New Regions[link]

The tracklang-region-codes.tex file isn’t automatically loaded, but if it is then, as from v1.4, it contains a hook at the end of the file that can be used to load additional files that define supplementary regions. This entails creating a file called, say, mypackage-regions.tex that contains:

    \TrackLangRegionMap{〈numeric code〉}{〈alpha-2
    code〉}{〈alpha-3 code〉}

where the first argument is the numeric region code (such as 826), the second argument is the alpha-2 region code (such as `GB`) and the third argument is the alpha-3 region code (such as `GBR`). Note that this command will override any previous mapping for those codes. No check is performed to determine if they have already been defined.

The supplementary file should be identified with:

    \TrackLangAddExtraRegionFile{〈filename〉}

Additional information can be found in §4.

[top]

## 6.5. Defining a New Language[link]

(New to version 1.3.) If the root language isn’t recognised by tracklang (not listed in Table 1.2), then it can be defined (but not tracked at this point) using:

📌
``\TrackLangNewLanguage`{〈language label〉}{〈639-1 code〉}{〈639-2 (T)〉}{〈639-2 (B)〉}{〈639-3〉}{〈3166-1〉}{〈default script〉}`
where 〈language label〉 is the root language label, 〈639-1 code〉 is the ISO 639-1 code for that language (may be empty if there isn’t one), 〈639-2 (T)〉 is the ISO 639-2 (T) code for that language (may be empty if there isn’t one), 〈639-2 (B)〉 is the ISO 639-2 (B) code for that language (may be empty if it’s the same as 〈639-2 (T)〉), 〈639-3〉 is the ISO 639-3 code for that language (empty if the same as the 639-2 code), 〈3166-1〉 is the territory ISO 3166-1 code for languages that are only spoken in one territory (should be empty if the language is spoken in multiple territories), and 〈default script〉 is the default script (empty if disputed or varies according to region).

You can then track this language using:

📌
``\AddTrackedDialect`{〈dialect label〉}{〈root language label〉}`
for dialects (where 〈dialect label〉 is the dialect label and 〈root language label〉 is the root language label) or, if no regional variant is needed, you can instead use:
📌
``\AddTrackedLanguage`{〈root language label〉}`
This is equivalent to

    \AddTrackedDialect{〈root language label〉}{〈root language label〉}

Note that `\AddTrackedDialect` defines:
📌
``\TrackLangLastTrackedDialect``
to the dialect label, which makes it easier to reference the last dialect to be tracked.

[top]

## 6.6. Defining New tracklang Labels[link]

A dialect label may be predefined with associated information that allows that particular combination to be easily tracked with `\TrackPredefinedDialect`. In the case of a dialect label that only requires the information provided in `\TrackLangNewLanguage` you can use:

📌
``\TrackLangProvidePredefinedLanguage`{〈language label〉}`
where 〈language label〉 corresponds to the language label used in `\TrackLangNewLanguage`. This allows

    \TrackPredefinedDialect{〈label〉}

to not only track the root language but also the associated ISO codes.

If the dialect label doesn’t match the root language label then use:

📌
``\TrackLangProvidePredefinedDialect`{〈dialect label〉}{〈root language label〉}{〈3166-1 code〉}{〈modifier〉}{〈variant〉}{〈map〉}{〈script〉}`
where 〈dialect label〉 is the new tracklang dialect label, {root language label} is the tracklang root language label, 〈region〉 is the ISO 3166-1 region code (may be empty), 〈modifier〉 is the modifier (may be empty), 〈variant〉 is the variant information (may be empty), 〈map〉 is your package’s language label that corresponds to the tracklang dialect label supplied in the first argument (may be empty if identical), and 〈script〉 is the ISO 15924 alpha-4 script code (may be empty if it’s the same as the default script for the root language).

For compatibility with pre version 1.3, if the dialect isn’t predefined by tracklang, then you can use:

    \AddTrackedDialect{〈dialect〉}{〈root language label〉}

where 〈root language label〉 is the label for the dialect’s root language (Table 1.2) and 〈dialect〉 matches the captions hook. If the dialect is already in the tracked dialect list, it won’t be added again. If the root language is already in the tracked language list, it won’t be added again. As from version 1.3 this additionally defines `\TrackLangLastTrackedDialect` to 〈dialect〉 for convenient reference if required. Note that `\AddTrackedDialect` is internally used by commands like `\TrackPredefinedDialect`, `\TrackLocale` and `\TrackLanguageTag`.

(New to version 1.3.) Many of the tracklang dialect labels don’t have a corresponding match in various language packages. For example, tracklang provides ngermanDE but the closest match in babel is ngerman. This means that the caption hook `\captionsngerman` can’t be accessed through:

    \csname captions\CurrentTrackedDialect\endcsname

in the resource files. In this case, a mapping may be defined between the tracklang dialect label and the closest matching label used by the language hooks. This is done through
📌
``\SetTrackedDialectLabelMap`{〈tracklang-label〉}{〈hook-label〉}`
where 〈tracklang-label〉 is the tracklang label and 〈hook-label〉 is the language hook label. For example:

    [fontupper=]
    \TrackLanguageTag{de-AR-1996}
    \SetTrackedDialectLabelMap
    {\TrackLangLastTrackedDialect}{ngerman}

Since `\TrackLanguageTag` internally uses `\AddTrackedDialect` the dialect label created by tracklang can be accessed using `\TrackLangLastTrackedDialect`. This means that `\TrackLangAddToCaptions` can now find the `\captionsngerman` hook even though the tracklang dialect label isn’t ngerman.

(New to version 1.3.) If the root language label is recognised by tracklang, you can add the ISO codes using:

📌
``\AddTrackedLanguageIsoCodes`{〈root language label〉}`

As from v1.3, you can also provide a modifier for a given dialect using:

📌
``\SetTrackedDialectModifier`{〈dialect〉}{〈value〉}`
where 〈dialect〉 is the dialect label and 〈value〉 is the modifier value. For example:

    \AddTrackedDialect{oldgerman}{german}
    \AddTrackedLanguageIsoCodes{german}
    \SetTrackedDialectModifier{oldgerman}{old}

Note that no sanitization is performed on 〈value〉 when the modifier is set explicitly through `\SetTrackedDialectModifier`, since it’s assumed that any package that specifically sets the modifier in this way is using a sensible labelling system. If the modifier is obtained through commands like `\TrackLocale`, then the modifier is sanitized as the value may have been obtained from the operating system and there’s no guarantee that it won’t contain problematic characters.

The modifier is typically obtained by parsing locale information in POSIX format.

    〈language〉[_〈territory〉][.〈codeset〉][@〈modifier〉]

whereas the variant is typically obtained by parsing the language tag.

The information provided in the commands below (such as the script) are typically obtained by parsing the language tag. For example, with Serbian in the Latin alphabet the modifier would be latin whereas the script would be Latn:

    🖹\AddTrackedDialect{serbianlatin}{serbian}
    \AddTrackedLanguageIsoCodes{serbian}
    \SetTrackedDialectModifier{serbianlatin}{latin}
    \SetTrackedDialectScript{serbianlatin}{Latn}

As from v1.3, you can provide a script (for example, Latn or Cyrl) using:

📌
``\SetTrackedDialectScript`{〈dialect〉}{〈value〉}`
where 〈dialect〉 is the dialect label and 〈value〉 is the ISO 15924 alpha-4 script identifier. For example:

    🖹\AddTrackedDialect{serbiancyrl}{serbian}
    \AddTrackedLanguageIsoCodes{serbian}
    \SetTrackedDialectScript{serbiancyrl}{Cyrl}

As from v1.3, you can provide a variant for a given dialect using:

📌
``\SetTrackedDialectVariant`{〈dialect〉}{〈value〉}`
For example:

    🖹\AddTrackedDialect{german1901}{german}
    \SetTrackedDialectVariant{german1901}{1901}

As from v1.3, you can also provide a sub-language using:

📌
``\SetTrackedDialectSubLang`{〈dialect〉}{〈value〉}`
where 〈dialect〉 is the dialect label and 〈value〉 is the code. For example:

    🖹\AddTrackedDialect{mandarin}{chinese}
    \AddTrackedLanguageIsoCodes{chinese}
    \SetTrackedDialectSubLang{mandarin}{cmn}
    \AddTrackedIsoLanguage{639-3}{cmn}{mandarin}

As from v1.3, you can also provide additional information using:

📌
``\SetTrackedDialectAdditional`{〈dialect〉}{〈value〉}`
where 〈dialect〉 is the dialect label and 〈value〉 is the additional information.

[top]

## 6.7. Example (alien.sty)[link]

Suppose I want to create a language package alien.sty that defines the martian language with regional dialects lowermartian and uppermartian. First, let’s suppose that tracklang recognises the root language martian:

    🖹\ProvidesPackage{alien}

    \inputtracklang% v1.3

    \DeclareOption{martian}{%
     \TrackPredefinedDialect{martian}
    }
    \DeclareOption{lowermartian}{%
     \AddTrackedDialect{lowermartian}{martian}
     \AddTrackedLanguageIsoCodes{martian}
     \AddTrackedIsoLanguage{3166-1}{YY}{lowermartian}
     % other attributes such as
     % \SetTrackedDialectVariant{lowermartian}{...}
    }
    \DeclareOption{uppermartian}{%
     \AddTrackedDialect{uppermartian}{martian}
     \AddTrackedLanguageIsoCodes{martian}
     \AddTrackedIsoLanguage{3166-1}{XX}{uppermartian}
     % other attributes such as
     % \SetTrackedDialectVariant{uppermartian}{...}
    }

    \ProcessOptions

    \newcommand*{\selectlanguage}[1]{%
     \def\languagename{#1}%
     % other stuff
     \SetCurrentTrackedDialect{#1}%

    }

    \AnyTrackedLanguages
    {
     \ForEachTrackedDialect{\thisdialect}
     {%
      \TrackLangRequireDialect{alien}{\thisdialect}
     }
    }

The caption commands and language set up are in the files alien-〈localeid〉.ldf as in the examples from §5.1. This allows for the user having already loaded tracklang before alien and used `\TrackLangFromEnv` to pick up the locale from the operating system’s environment variables. (For example, they may have `LANG` set to `xx`_`YY`.)

The resource files may need to set the mapping between the tracklang dialect label and the alien dialect label. For example, in alien-xx-YY.ldf:

    🖹\TrackLangProvidesResource{xx-YY}

    \TrackLangRequireResource{martian}% load common elements

    \newcommand{\captionslowermartian}{%
     \captionsmartian
     \def\contentsname{X'flurp}% regional variation
    }

    \SetTrackedDialectLabelMap{\CurrentTrackedDialect}{lowermartian}

Now let’s consider the case where tracklang doesn’t know about the martian language. In this case the user can’t track the dialect until the root language has been defined, so the user can’t use `\TrackLangFromEnv` before using the alien package.

With tracklang v1.3. The new root language can be defined with a minor adjustment to the above code:

    🖹\ProvidesPackage{alien}

    \input{tracklang}% needs v1.3

    \TrackLangIfKnownLang{martian}
    {% tracklang already knows about the martian language
    }%
    {
     % tracklang doesn't known about the martian language,
     % so define it
     % with ISO 639-1 (xx) and ISO 639-2 (xxx) codes:
     \TrackLangNewLanguage{martian}{xx}{xxx}{}{}{}{Latn}
    }

The rest is as before.

Now other package writers who want to provide support for the Martian dialects can easily detect which language options the user requested through my package, without needing to know anything about my alien package.

[top]
II. Summaries[link]

[top]

# A. Region and Script Mappings[link]

Region mappings are listed in Table A.1, and script mappings are listed in Table A.2.

Table A.1: Region Mappings
Alpha-2 | Alpha-3 | Numeric | Alpha-2 | Alpha-3 | Numeric
--- | --- | --- | --- | --- | ---
AD | AND | 020 | AE | ARE | 784
AF | AFG | 004 | AG | ATG | 028
AI | AIA | 660 | AL | ALB | 008
AM | ARM | 051 | AO | AGO | 024
AQ | ATA | 010 | AR | ARG | 032
AS | ASM | 016 | AT | AUT | 040
AU | AUS | 036 | AW | ABW | 533
AX | ALA | 248 | AZ | AZE | 031
BA | BIH | 070 | BB | BRB | 052
BD | BGD | 050 | BE | BEL | 056
BF | BFA | 854 | BG | BGR | 100
BH | BHR | 048 | BI | BDI | 108
BJ | BEN | 204 | BL | BLM | 652
BM | BMU | 060 | BN | BRN | 096
BO | BOL | 068 | BQ | BES | 535
BR | BRA | 076 | BS | BHS | 044
BT | BTN | 064 | BV | BVT | 074
BW | BWA | 072 | BY | BLR | 112
BZ | BLZ | 084 | CA | CAN | 124
CC | CCK | 166 | CD | COD | 180
CF | CAF | 140 | CG | COG | 178
CH | CHE | 756 | CI | CIV | 384
CK | COK | 184 | CL | CHL | 152
CM | CMR | 120 | CN | CHN | 156
CO | COL | 170 | CR | CRI | 188
CU | CUB | 192 | CV | CPV | 132
CW | CUW | 531 | CX | CXR | 162
CY | CYP | 196 | CZ | CZE | 203
DE | DEU | 276 | DJ | DJI | 262
DK | DNK | 208 | DM | DMA | 212
DO | DOM | 214 | DZ | DZA | 012
EC | ECU | 218 | EE | EST | 233
EG | EGY | 818 | EH | ESH | 732
ER | ERI | 232 | ES | ESP | 724
ET | ETH | 231 | FI | FIN | 246
FJ | FJI | 242 | FK | FLK | 238
FM | FSM | 583 | FO | FRO | 234
FR | FRA | 250 | GA | GAB | 266
GB | GBR | 826 | GD | GRD | 308
GE | GEO | 268 | GF | GUF | 254
GG | GGY | 831 | GH | GHA | 288
GI | GIB | 292 | GL | GRL | 304
GM | GMB | 270 | GN | GIN | 324
GP | GLP | 312 | GQ | GNQ | 226
GR | GRC | 300 | GS | SGS | 239
GT | GTM | 320 | GU | GUM | 316
GW | GNB | 624 | GY | GUY | 328
HK | HKG | 344 | HM | HMD | 334
HN | HND | 340 | HR | HRV | 191
HT | HTI | 332 | HU | HUN | 348
ID | IDN | 360 | IE | IRL | 372
IL | ISR | 376 | IM | IMN | 833
IN | IND | 356 | IO | IOT | 086
IQ | IRQ | 368 | IR | IRN | 364
IS | ISL | 352 | IT | ITA | 380
JE | JEY | 832 | JM | JAM | 388
JO | JOR | 400 | JP | JPN | 392
KE | KEN | 404 | KG | KGZ | 417
KH | KHM | 116 | KI | KIR | 296
KM | COM | 174 | KN | KNA | 659
KP | PRK | 408 | KR | KOR | 410
KW | KWT | 414 | KY | CYM | 136
KZ | KAZ | 398 | LA | LAO | 418
LB | LBN | 422 | LC | LCA | 662
LI | LIE | 438 | LK | LKA | 144
LR | LBR | 430 | LS | LSO | 426
LT | LTU | 440 | LU | LUX | 442
LV | LVA | 428 | LY | LBY | 434
MA | MAR | 504 | MC | MCO | 492
MD | MDA | 498 | ME | MNE | 499
MF | MAF | 663 | MG | MDG | 450
MH | MHL | 584 | MK | MKD | 807
ML | MLI | 466 | MM | MMR | 104
MN | MNG | 496 | MO | MAC | 446
MP | MNP | 580 | MQ | MTQ | 474
MR | MRT | 478 | MS | MSR | 500
MT | MLT | 470 | MU | MUS | 480
MV | MDV | 462 | MW | MWI | 454
MX | MEX | 484 | MY | MYS | 458
MZ | MOZ | 508 | NA | NAM | 516
NC | NCL | 540 | NE | NER | 562
NF | NFK | 574 | NG | NGA | 566
NI | NIC | 558 | NL | NLD | 528
NO | NOR | 578 | NP | NPL | 524
NR | NRU | 520 | NU | NIU | 570
NZ | NZL | 554 | OM | OMN | 512
PA | PAN | 591 | PE | PER | 604
PF | PYF | 258 | PG | PNG | 598
PH | PHL | 608 | PK | PAK | 586
PL | POL | 616 | PM | SPM | 666
PN | PCN | 612 | PR | PRI | 630
PS | PSE | 275 | PT | PRT | 620
PW | PLW | 585 | PY | PRY | 600
QA | QAT | 634 | RE | REU | 638
RO | ROU | 642 | RS | SRB | 688
RU | RUS | 643 | RW | RWA | 646
SA | SAU | 682 | SB | SLB | 090
SC | SYC | 690 | SD | SDN | 729
SE | SWE | 752 | SG | SGP | 702
SH | SHN | 654 | SI | SVN | 705
SJ | SJM | 744 | SK | SVK | 703
SL | SLE | 694 | SM | SMR | 674
SN | SEN | 686 | SO | SOM | 706
SR | SUR | 740 | SS | SSD | 728
ST | STP | 678 | SV | SLV | 222
SX | SXM | 534 | SY | SYR | 760
SZ | SWZ | 748 | TC | TCA | 796
TD | TCD | 148 | TF | ATF | 260
TG | TGO | 768 | TH | THA | 764
TJ | TJK | 762 | TK | TKL | 772
TL | TLS | 626 | TM | TKM | 795
TN | TUN | 788 | TO | TON | 776
TR | TUR | 792 | TT | TTO | 780
TV | TUV | 798 | TW | TWN | 158
TZ | TZA | 834 | UA | UKR | 804
UG | UGA | 800 | UM | UMI | 581
US | USA | 840 | UY | URY | 858
UZ | UZB | 860 | VA | VAT | 336
VC | VCT | 670 | VE | VEN | 862
VG | VGB | 092 | VI | VIR | 850
VN | VNM | 704 | VU | VUT | 548
WF | WLF | 876 | WS | WSM | 882
YE | YEM | 887 | YT | MYT | 175
ZA | ZAF | 710 | ZM | ZMB | 894
ZW | ZWE | 716 |

Table A.2: Script Mappings
Alpha-2 | Numeric | Direction | Description
--- | --- | --- | ---
Adlm | 166 | RL | Adlam.
Afak | 439 | varies | Afaka.
Aghb | 239 | LR | Caucasian Albanian.
Ahom | 338 | LR | Ahom, Tai Ahom.
Arab | 160 | RL | Arabic.
Aran | 161 | RL | Arabic (Nastaliq variant).
Armi | 124 | RL | Imperial Aramaic.
Armn | 230 | LR | Armenian.
Avst | 134 | RL | Avestan.
Bali | 360 | LR | Balinese.
Bamu | 435 | LR | Bamum.
Bass | 259 | LR | Bassa Vah.
Batk | 365 | LR | Batak.
Beng | 334 | LR | Bhaiksuki.
Blis | 550 | varies | Blissymbols.
Bopo | 285 | LR | Bopomofo.
Brah | 300 | LR | Brahmi.
Brai | 570 | LR | Braille.
Bugi | 367 | LR | Buginese.
Buhd | 372 | LR | Buhid.
Cakm | 349 | LR | Chakma.
Cans | 440 | LR | Unified Canadian Aboriginal Syllabics.
Cari | 201 | LR | Carian.
Cham | 358 | LR | Cham.
Cher | 445 | LR | Cherokee.
Cirt | 291 | varies | Cirth.
Copt | 204 | LR | Coptic.
Cprt | 403 | RL | Cypriot.
Cyrl | 220 | LR | Cyrillic.
Cyrs | 221 | varies | Cyrillic (Old Church Slavonic variant).
Deva | 315 | LR | Devanagari (Nagari).
Dsrt | 250 | LR | Deseret (Mormon).
Dupl | 755 | LR | Duployan shorthand, Duployan stenography.
Egyd | 070 | RL | Egyptian demotic.
Egyh | 060 | RL | Egyptian hieratic.
Egyp | 050 | LR | Egyptian hieroglyphs.
Elba | 226 | LR | Elbasan.
Ethi | 430 | LR | Ethiopic (Ge’ez).
Geok | 241 | LR | Khutsuri (Asomtavruli and Nuskhuri).
Geor | 240 | LR | Georgian (Mkhedruli).
Glag | 225 | LR | Glagolitic.
Goth | 206 | LR | Gothic.
Gran | 343 | LR | Grantha.
Grek | 200 | LR | Greek.
Gujr | 320 | LR | Gujarati.
Guru | 310 | LR | Gurmukhi.
Hanb | 503 | LR | Han with Bopomofo (alias for Han + Bopomofo).
Hang | 286 | LR | Hangul.
Hani | 500 | LR | Han (Hanzi, Kanji, Hanja).
Hano | 371 | LR | Hanunoo.
Hans | 501 | varies | Han (Simplified variant).
Hant | 502 | varies | Han (Traditional variant).
Hatr | 127 | RL | Hatran.
Hebr | 125 | RL | Hebrew.
Hira | 410 | LR | Hiragana.
Hluw | 080 | LR | Anatolian Hieroglyphs (Luwian Hieroglyphs, Hittite Hieroglyphs).
Hmng | 450 | LR | Pahawh Hmong.
Hrkt | 412 | varies | Japanese syllabaries (alias for Hiragana + Katakana).
Hung | 176 | RL | Old Hungarian (Hungarian Runic).
Inds | 610 | RL | Indus (Harappan).
Ital | 210 | LR | Old Italic (Etruscan, Oscan, etc.)
Jamo | 284 | LR | Jamo (alias for Jamo subset of Hangul).
Java | 361 | LR | Javanese.
Jpan | 413 | varies | Japanese (alias for Han + Hiragana + Katakana).
Jurc | 510 | LR | Jurchen.
Kali | 357 | LR | Kayah Li.
Kana | 411 | LR | Katakana.
Khar | 305 | RL | Kharoshthi.
Khmr | 355 | LR | Khmer.
Khoj | 322 | LR | Khojki.
Kitl | 505 | LR | Khitan large script.
Kits | 288 | TB | Khitan small script.
Knda | 345 | LR | Kannada.
Kore | 287 | LR | Korean (alias for Hangul + Han).
Kpel | 436 | LR | Kpelle.
Kthi | 317 | LR | Kaithi.
Lana | 351 | LR | Tai Tham (Lanna).
Laoo | 356 | LR | Lao.
Latf | 217 | varies | Latin (Fraktur variant).
Latg | 216 | LR | Latin (Gaelic variant).
Latn | 215 | LR | Latin.
Leke | 364 | LR | Leke.
Lepc | 335 | LR | Lepcha.
Limb | 336 | LR | Limbu.
Lina | 400 | LR | Linear A.
Linb | 401 | LR | Linear B.
Lisu | 399 | LR | Lisu (Fraser).
Loma | 437 | LR | Loma.
Lyci | 202 | LR | Lycian.
Lydi | 116 | RL | Lydian.
Mahj | 314 | LR | Mahajani.
Mand | 140 | RL | Mandaic, Mandaean.
Mani | 139 | RL | Manichaean.
Marc | 332 | LR | Marchen.
Maya | 090 | varies | Mayan hieroglyphs.
Mend | 438 | RL | Mende Kikakui.
Merc | 101 | RL | Meroitic Cursive.
Mero | 100 | RL | Meroitic Hieroglyphs.
Mlym | 347 | LR | Malayalam.
Modi | 324 | LR | Modi.
Mong | 145 | TB | Mongolian.
Moon | 218 | varies | Moon (Moon code, Moon script, Moon type).
Mroo | 199 | LR | Mro, Mru.
Mtei | 337 | LR | Meitei Mayek (Meithei, Meetei).
Mult | 323 | LR | Multani.
Mymr | 350 | LR | Myanmar (Burmese).
Narb | 106 | RL | Old North Arabian (Ancient North Arabian).
Nbat | 159 | RL | Nabataean.
Newa | 333 | LR | Newa, Newar, Newari.
Nkgb | 420 | LR | Nakhi Geba.
Nkoo | 165 | RL | N’Ko.
Nshu | 499 | LR | Nushu.
Ogam | 212 | varies | Ogham.
Olck | 261 | LR | Ol Chiki.
Orkh | 175 | RL | Old Turkic, Orkhon Runic.
Orya | 327 | LR | Oriya.
Osge | 219 | LR | Osage.
Osma | 260 | LR | Osmanya.
Palm | 126 | RL | Palmyrene.
Pauc | 263 | LR | Pau Cin Hau.
Perm | 227 | LR | Old Permic.
Phag | 331 | TB | Phags-pa.
Phli | 131 | RL | Inscriptional Pahlavi.
Phlp | 132 | RL | Psalter Pahlavi.
Phlv | 133 | RL | Book Pahlavi.
Phnx | 115 | RL | Phoenician.
Piqd | 293 | LR | Klingon (KLI plqaD).
Plrd | 282 | LR | Miao (Pollard).
Prti | 130 | RL | Inscriptional Parthian.
Qaaa | 900 | varies | Reserved for private use (start).
Qaai | 908 | varies | Private use.
Qabx | 949 | varies | Reserved for private use (end).
Rjng | 363 | LR | Rejang (Redjang, Kaganga).
Roro | 620 | varies | Rongorongo.
Runr | 211 | LR | Runic.
Samr | 123 | RL | Samaritan.
Sara | 292 | varies | Sarati.
Sarb | 105 | RL | Old South Arabian.
Saur | 344 | LR | Saurashtra.
Sgnw | 095 | TB | SignWriting.
Shaw | 281 | LR | Shavian (Shaw).
Shrd | 319 | LR | Sharada.
Sidd | 302 | LR | Siddham.
Sind | 318 | LR | Khudawadi, Sindhi.
Sinh | 348 | LR | Sinhala.
Sora | 398 | LR | Sora Sompeng.
Sund | 362 | LR | Sundanese.
Sylo | 316 | LR | Syloti Nagri.
Syrc | 135 | RL | Syriac.
Syre | 138 | RL | Syriac (Estrangelo variant).
Syrj | 137 | RL | Syriac (Western variant).
Syrn | 136 | RL | Syriac (Eastern variant).
Tagb | 373 | LR | Tagbanwa.
Takr | 321 | LR | Takri.
Tale | 353 | LR | Tai Le.
Talu | 354 | LR | New Tai Lue.
Taml | 346 | LR | Tamil.
Tang | 520 | LR | Tangut.
Tavt | 359 | LR | Tai Viet.
Telu | 340 | LR | Telugu.
Teng | 290 | LR | Tengwar.
Tfng | 120 | LR | Tifinagh (Berber).
Tglg | 370 | LR | Tagalog (Baybayin, Alibata).
Thaa | 170 | RL | Thaana.
Thai | 352 | LR | Thai.
Tibt | 330 | LR | Tibetan.
Tirh | 326 | LR | Tirhuta.
Ugar | 040 | LR | Ugaritic.
Vaii | 470 | LR | Vai.
Visp | 280 | LR | Visible Speech.
Wara | 262 | LR | Warang Citi (Varang Kshiti).
Wole | 480 | RL | Woleai.
Xpeo | 030 | LR | Old Persian.
Xsux | 020 | LR | Cuneiform, Sumero-Akkadian.
Yiii | 460 | LR | Yi.
Zinh | 994 | inherited | Inherited script.
Zmth | 995 | LR | Mathematical notation.
Zsye | 993 | varies | Symbols (emoji variant).
Zsym | 996 | varies | Symbols.
Zxxx | 997 | varies | Unwritten documents.
Zyyy | 998 | varies | Undetermined script.
Zzzz | 999 | varies | Uncoded script.

[top]

# Symbols[link]

📌
  The syntax and usage of a command, environment or option etc.
ℹ
  An important message.
🛈
  Prominent information.
🖹
  LaTeX code to insert into your document.
🖺
  How the example code should appear in the PDF.
〉_
  A command-line application invocation that needs to be entered into a terminal or command prompt.
𝍢
  An option that doesn’t take a value.

[top]

# Glossary[link]

Command-line interface (CLI)
  An application that doesn’t have a graphical user interface. That is, an application that doesn’t have any windows, buttons or menus and can be run in a command prompt or terminal.
Shell escape
  TeX has the ability to run CLI applications while it’s typesetting a document. Whilst this is a convenient way of using tools to help build the document, it’s a security risk. To help protect users from arbitrary—and potentially dangerous—code from begin executed, TeX has a restricted mode, where only trusted applications are allowed to run. This is usually the default mode, but your TeX installation may be set up so that the shell escape is disabled by default. The unrestricted mode allows you to run any application from the shell escape. Take care about enabling this option. If you receive a document or package from an untrusted source, first run TeX with the shell escape disabled or in restricted mode and search the log file for “runsystem” before using the unrestricted mode. Note that LuaLaTeX additionally requires the shellesc package.

[top]

# Command Summary[link]

[top]

## @[link]

`\@tracklang@declareoption``{〈dialect〉}`tracklang v1.1+

Provided by tracklang.sty to declare 〈dialect〉 as a package option that tracks 〈dialect〉. Provided by tracklang.tex, if not already defined, to ignore its argument. §3; 19

`\@tracklang@for``〈cs〉:=〈list〉\do{〈body〉}`tracklang.tex v1.0+

As LaTeX’s `\@for`. §5; 37

`\@tracklang@prelangpkgcheck@hook`

If defined before tracklang.sty v1.3.8+ is loaded, this command will be done after package options have been processed but before the check for language packages, such as babel and polyglossia. §6; 72

[top]

## A[link]

`\AddTrackedCountryIsoCode``{〈language〉}`tracklang.tex v1.3+

Adds the ISO 3166-1 code.

`\AddTrackedDialect``{〈dialect label〉}{〈root language label〉}`tracklang.tex v1.0+

Tracks a dialect. This command defines `\TrackLangLastTrackedDialect` to provide a convenient way to reference the last dialect to be tracked. §6.5; 76

`\AddTrackedIsoLanguage``{〈code type〉}{〈code〉}{〈language〉}`tracklang.tex v1.0+

Adds a mapping between the given ISO code and language name.

`\AddTrackedLanguage``{〈root language label〉}`tracklang.tex v1.0+

Shortcut for ``\AddTrackedDialect`{〈root language label〉}{〈root language label〉}`. §6.5; 76

`\AddTrackedLanguageIsoCodes``{〈root language label〉}`tracklang.tex v1.3+

Adds the ISO 639-1, 639-2 and 639-3 codes, which must have previously been declared using `\TrackLangNewLanguage`. §6.6; 78

`\AnyTrackedLanguages``{〈true〉}{〈false〉}`tracklang.tex v1.0+

Expands to 〈true〉 if there are any tracked languages, otherwise expands to 〈false〉. §5; 35

`\AnyTrackedRegions``{〈true〉}{〈false〉}`tracklang.tex v1.6.3+

Expands to 〈true〉 if there are any tracked regions, otherwise expands to 〈false〉. §5; 36

[top]

## C[link]

`\CurrentTrackedDialect` tracklang.tex v1.3+

Defined by `\SetCurrentTrackedDialect` to the dialect label, which may be the supplied 〈dialect〉 label or the mapped label or, if 〈dialect〉 is a root language label, the last tracked dialect for the given root language. §5; 47

`\CurrentTrackedDialectAdditional` tracklang.tex v1.3+

Defined by `\SetCurrentTrackedDialect` to the additional part associated with the dialect (may be empty). §5; 47

`\CurrentTrackedDialectModifier` tracklang.tex v1.3+

Defined by `\SetCurrentTrackedDialect` to the associated modifier (may be empty). §5; 47

`\CurrentTrackedDialectScript` tracklang.tex v1.3+

Defined by `\SetCurrentTrackedDialect` to the script associated with the dialect, or to the default script for the language. §5; 48

`\CurrentTrackedDialectSubLang` tracklang.tex v1.3+

Defined by `\SetCurrentTrackedDialect` to the sub language associated with the dialect (may be empty). §5; 47

`\CurrentTrackedDialectVariant` tracklang.tex v1.3+

Defined by `\SetCurrentTrackedDialect` to the associated variant (may be empty). §5; 47

`\CurrentTrackedIsoCode` tracklang.tex v1.3+

Defined by `\SetCurrentTrackedDialect` to the ISO 639-1 or 639-2 or 639-3 language code (may be empty). §5; 47

`\CurrentTrackedLanguage` tracklang.tex v1.3+

Defined by `\SetCurrentTrackedDialect` to the associated root language label. §5; 47

`\CurrentTrackedLanguageTag` tracklang.tex v1.3+

Defined by `\SetCurrentTrackedDialect` to the language tag that identifies the dialect or und if no match. §5; 47

`\CurrentTrackedRegion` tracklang.tex v1.3+

Defined by `\SetCurrentTrackedDialect` to the ISO 3166-1 region code associated with the dialect (may be empty). §5; 47

`\CurrentTrackedTag` tracklang.tex v1.0+

Expands to the current tracked tag. §5; 45

[top]

## F[link]

`\ForEachTrackedDialect``{〈cs〉}{〈body〉}`tracklang.tex v1.0+

Iterates through the list of tracked dialects. On each iteration 〈cs〉 is set to the dialect tag and 〈body〉 is performed. §5; 37

`\ForEachTrackedLanguage``{〈cs〉}{〈body〉}`tracklang.tex v1.0+

Iterates through the list of tracked languages. On each iteration 〈cs〉 is set to the language tag and 〈body〉 is performed. §5; 37

`\ForEachTrackedRegion``{〈cs〉}{〈body〉}`tracklang.tex v1.0+

Iterates through the list of tracked regions. On each iteration 〈cs〉 is set to the region code and 〈body〉 is performed. §5; 37

[top]

## G[link]

`\GetTrackedDialectAdditional``{〈dialect〉}`tracklang.tex v1.3+

Expands to the extra information for 〈dialect〉. §5; 44

`\GetTrackedDialectFromLanguageTag``{〈tag〉}{〈cs〉}`tracklang.tex v1.3+

Finds the tracked dialect that matches the given language tag and stores the dialect label in 〈cs〉. If no match found, 〈cs〉 will be empty. §5; 36

`\GetTrackedDialectModifier``{〈dialect〉}`tracklang.tex v1.3+

Expands to the modifier for the given dialect. §5; 41

`\GetTrackedDialectScript``{〈dialect〉}`tracklang.tex v1.3+

Expands to the script for 〈dialect〉. §5; 42

`\GetTrackedDialectSubLang``{〈dialect〉}`tracklang.tex v1.3+

Expands to the sub-language for 〈dialect〉. §5; 44

`\GetTrackedDialectVariant``{〈dialect〉}`tracklang.tex v1.3+

Expands to the modifier for 〈dialect〉. §5; 42

`\GetTrackedLanguageTag``{〈dialect〉}`tracklang.tex v1.3+

Gets the language tag for 〈dialect〉. §5; 40

[top]

## I[link]

`\IfHasTrackedDialectAdditional``{〈dialect〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Expands to 〈true〉 if there’s extra information for 〈dialect〉, otherwise expands to 〈false〉. §5; 44

`\IfHasTrackedDialectModifier``{〈dialect〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Expands to 〈true〉 if there’s a modifier for the given dialect, otherwise expands to 〈false〉. §5; 41

`\IfHasTrackedDialectScript``{〈dialect〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Expands to 〈true〉 if there’s a script for 〈dialect〉, otherwise expands to 〈false〉. §5; 43

`\IfHasTrackedDialectSubLang``{〈dialect〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Expands to 〈true〉 if there’s a sub-language for 〈dialect〉, otherwise expands to 〈false〉. §5; 44

`\IfHasTrackedDialectVariant``{〈dialect〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Expands to 〈true〉 if there’s a modifier for 〈dialect〉, otherwise expands to 〈false〉. §5; 42

`\IfTrackedDialect``{〈dialect-label〉}{〈true〉}{〈false〉}`tracklang.tex v1.0+

Does 〈true〉 if the dialect identified by 〈dialect-label〉 has been tracked, otherwise does 〈false〉. §5; 38

`\IfTrackedDialectIsScriptCs``{〈dialect〉}{〈cs〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

If the given tracked dialect has an associated script and that script code matches the replacement text for the control sequence 〈cs〉 then do 〈true〉 otherwise to 〈false〉. If the tracked dialect doesn’t have an associated script then the default script for the root language is tested. §5; 43

`\IfTrackedIsoCode``{〈code type〉}{〈code〉}{〈true〉}{〈false〉}`tracklang.tex v1.0+

Does 〈true〉 if the given ISO code has been defined otherwise does 〈false〉. §5; 39

`\IfTrackedLanguage``{〈language-label〉}{〈true〉}{〈false〉}`tracklang.tex v1.0+

Does 〈true〉 if the language identified by 〈language-label〉 has been tracked, otherwise does 〈false〉. §5; 38

`\IfTrackedLanguageFileExists``{〈dialect〉}{〈prefix〉}{〈suffix〉}{〈true code〉}{〈false code〉}`tracklang.tex v1.0+

Does ``\SetCurrentTrackedDialect`{〈dialect〉}` and if the dialect is recognised, then determines if the file 〈prefix〉〈tag〉〈suffix〉 exists. If it does, `\CurrentTrackedTag` is set to 〈tag〉 and 〈true〉 is done, otherwise 〈false〉 is done. §5; 45

`\IfTrackedLanguageFileExistsOmitDialectLabel``{〈dialect〉}{〈prefix〉}{〈suffix〉}{〈true code〉}{〈false code〉}`tracklang.tex v1.6.3+

As `\IfTrackedLanguageFileExists` but skips the dialect label check. Note that if the dialect label happens to be the same as the root label, it will still be checked but at the end instead of near the start. §5; 45

`\IfTrackedLanguageFileExistsOmitDialectLabelOmitOnlyRegion``{〈dialect〉}{〈prefix〉}{〈suffix〉}{〈true code〉}{〈false code〉}`tracklang.tex v1.6.3+

As `\IfTrackedLanguageFileExists` but skips the dialect label check and just the region code check. Note that if the dialect label happens to be the same as the root label, it will still be checked but at the end instead of near the start. §5; 45

`\IfTrackedLanguageFileExistsOmitOnlyRegion``{〈dialect〉}{〈prefix〉}{〈suffix〉}{〈true code〉}{〈false code〉}`tracklang.tex v1.6.3+

As `\IfTrackedLanguageFileExists` but skips the solo region code check. §5; 45

`\IfTrackedLanguageHasIsoCode``{〈code type〉}{〈label〉}{〈true〉}{〈false〉}`tracklang.tex v1.0+

Does 〈true〉 if the given language or dialect has a corresponding ISO code of the given type, otherwise does 〈false〉. §5; 39

`\ifTrackLangShowInfo``〈true〉`\else` 〈false〉`\fi``initial: `\iftrue`; tracklang.tex v1.3+

Conditional that indicates whether or not to show information messages.

`\ifTrackLangShowVerbose``〈true〉`\else` 〈false〉`\fi``initial: `\iffalse`; tracklang.tex v1.4+

Conditional that indicates whether or not to show verbose messages.

`\ifTrackLangShowWarnings``〈true〉`\else` 〈false〉`\fi``initial: `\iftrue`; tracklang.tex v1.3+

Conditional that indicates whether or not to show warnings.

[top]

## S[link]

`\SetCurrentTrackedDialect``{〈dialect〉}`tracklang.tex v1.3+

Sets the current tracked dialect. §6.2; 74

`\SetTrackedDialectAdditional``{〈dialect〉}{〈value〉}`tracklang.tex v1.3+

Sets the extra information for 〈dialect〉 to 〈value〉. §6.6; 80

`\SetTrackedDialectLabelMap``{〈tracklang-label〉}{〈hook-label〉}`tracklang.tex v1.3+

Defines a mapping between a tracklang dialect label and the corresponding dialect label used by a language hook, such as `\captions〈dialect〉`. §6.6; 78

`\SetTrackedDialectModifier``{〈dialect〉}{〈value〉}`tracklang.tex v1.3+

Sets the modifier for the given 〈dialect〉 to 〈value〉. §6.6; 78

`\SetTrackedDialectScript``{〈dialect〉}{〈value〉}`tracklang.tex v1.3+

Sets the script for 〈dialect〉 to 〈value〉. §6.6; 79

`\SetTrackedDialectSubLang``{〈dialect〉}{〈value〉}`tracklang.tex v1.3+

Sets the sub-language for 〈dialect〉 to 〈value〉. §6.6; 80

`\SetTrackedDialectVariant``{〈dialect〉}{〈value〉}`tracklang.tex v1.3+

Sets the modifier for 〈dialect〉 to 〈value〉. §6.6; 79

[top]

## T[link]

`\ThreeLetterExtIsoLanguageCode` tracklang.tex v1.3+

Expands to 639-3 (should not be redefined). §5; 40

`\ThreeLetterIsoLanguageCode` tracklang.tex v1.0+

Expands to 639-2 (should not be redefined). §5; 40

`\TrackedDialectClosestSubMatch` tracklang.tex v1.3.6+

Defined by `\GetTrackedDialectFromLanguageTag` to the closest match. §5; 36

`\TrackedDialectsFromLanguage``{〈root language label〉}`tracklang.tex v1.0+

Expands to a comma-separated list of the tracked dialects with the given language. §5; 39

`\TrackedIsoCodeFromLanguage``{〈code type〉}{〈label〉}`tracklang.tex v1.0+

Expands to the code associated with the given language or dialect identified by 〈label〉. §5; 40

`\TrackedLanguageFromDialect``{〈dialect〉}`tracklang.tex v1.0+

Expands to the language from the given dialect. §5; 39

`\TrackedLanguageFromIsoCode``{〈code type〉}{〈code〉}`tracklang.tex v1.0+

Expands to a comma-separated list of language or dialect labels associated with the given code. §5; 39

`\TrackIfKnownLanguage``{〈tag〉}{〈success code〉}{〈fail code〉}`tracklang.tex v1.3.9+

As `\TrackLanguageTag` but does 〈fail code〉 if the tag doesn’t contain a valid language code. If successful, does 〈success code〉 after tracking the language. §3; 21

`\TrackLangAddExtraRegionFile``{〈file〉}`tracklang.tex v1.4+

Adds 〈file〉 to the list of extra region code files that should be input by tracklang-region-codes.tex. §4; 31

`\TrackLangAddExtraScriptFile``{〈file〉}`tracklang.tex v1.4+

Adds 〈file〉 to the list of files that should be input by tracklang-scripts.tex. §4; 33

`\TrackLangAddToCaptions``{〈code〉}`tracklang.tex v1.3+

A shortcut that just does ``\TrackLangAddToHook`{〈code〉}{captions}`. §5; 56

`\TrackLangAddToHook``{〈code〉}{〈type〉}`tracklang.tex v1.3+

For use within resource files, this can be used to add 〈code〉 to the appropriate hook. §5; 55

`\TrackLangAlphaIIIToNumericRegion``{〈alpha-3 code〉}`tracklang-region-codes.tex v1.3+

Expands to the numeric code corresponding to the given alpha-3 code. §4; 30

`\TrackLangAlphaIIToNumericRegion``{〈alpha-2 code〉}`tracklang-region-codes.tex v1.3+

Expands to the numeric code corresponding to the given alpha-2 code. §4; 30

`\TrackLangDeclareDialectOption``{〈dialect〉}{〈root language〉}{〈3166-1 code〉}{〈modifier〉}{〈variant〉}{〈map〉}{〈script〉}`tracklang.tex v1.3+

Defines a predefined dialect label that can be used by `\TrackPredefinedDialect`.

`\TrackLangDeclareLanguageOption``{〈language name〉}{〈639-1 code〉}{〈639-2 (T)〉}{〈639-2 (B)〉}{〈639-3〉}{〈3166-1〉}{〈default script〉}`tracklang.tex v1.3+

Defines a new root language that’s declared as an option.

`\TrackLangEncodingName` tracklang.tex v1.6.1+

Expands to `\inputencodingname` if it has been defined or `utf8` otherwise. §5; 54

`\TrackLangEnv`

(user defined)

May be defined using the same format as `LC_ALL` before using `\TrackLangParseFromEnv` to skip the environment variable query. §3; 25

`\TrackLangEnvCodeSet` tracklang.tex v1.3+

Set by `\TrackLangParseFromEnv` to the code-set. §3; 26

`\TrackLangEnvLang` tracklang.tex v1.3+

Set by `\TrackLangParseFromEnv` to the language code. §3; 26

`\TrackLangEnvModifier` tracklang.tex v1.3+

Set by `\TrackLangParseFromEnv` to the modifier. §3; 26

`\TrackLangEnvTerritory` tracklang.tex v1.3+

Set by `\TrackLangParseFromEnv` to the territory. §3; 26

`\TrackLangFromEnv` tracklang.tex v1.3+

Queries environment variable if `\TrackLangEnv` not already set, parses `\TrackLangEnv` if it has been set, and adds the dialect if it’s recognised. §3; 23

`\TrackLangGetDefaultScript``{〈language〉}`tracklang.tex v1.3+

Expands to the default script for the given language. §5; 43

`\TrackLangGetKnownCountry``{〈language〉}`tracklang.tex v1.3+

Expands to the ISO 3166-1 country code for the given language.

`\TrackLangGetKnownIsoThreeLetterLang``{〈language〉}`tracklang.tex v1.3+

Expands to the ISO 639-2 language code associated with 〈language〉.

`\TrackLangGetKnownIsoThreeLetterLangB``{〈language〉}`tracklang.tex v1.3+

Expands to the ISO 639-2 (B) language code associated with 〈language〉.

`\TrackLangGetKnownIsoTwoLetterLang``{〈language〉}`tracklang.tex v1.3+

Expands to the ISO 639-1 language code associated with 〈language〉.

`\TrackLangGetKnownLangFromIso``{〈ISO code〉}`tracklang.tex v1.3+

Expands to the root language label from the given ISO code (639-1 or 639-2 or 639-3).

`\TrackLangIfAlphaNumericChar``{〈tag〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Does 〈true〉 if the argument is a single alphanumeric character otherwise does 〈false〉.

`\TrackLangIfHasDefaultScript``{〈language〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Does 〈true〉 if the given language has a default script (but is not necessarily tracked), otherwise does 〈false〉.

`\TrackLangIfHasKnownCountry``{〈language〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Does 〈true〉 if the given language has an ISO 3166-1 country code (but is not necessarily tracked), otherwise does 〈false〉.

`\TrackLangIfKnownAlphaIIIRegion``{〈alpha-3 code〉}{〈true〉}{〈false〉}`tracklang-region-codes.tex v1.3+

Expands to 〈true〉 if there’s a known mapping for the given 〈alpha-3 code〉, otherwise expands to 〈false〉. §4; 31

`\TrackLangIfKnownAlphaIIRegion``{〈alpha-2 code〉}{〈true〉}{〈false〉}`tracklang-region-codes.tex v1.3+

Expands to 〈true〉 if there’s a known mapping for the given alpha-2 region code, otherwise expands to 〈false〉. §4; 30

`\TrackLangIfKnownIsoThreeLetterLang``{〈language〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Does 〈true〉 if 〈language〉 has an ISO 639-2 code (but is not necessarily tracked), otherwise does 〈false〉.

`\TrackLangIfKnownIsoThreeLetterLangB``{〈language〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Does 〈true〉 if 〈language〉 has an ISO 639-2 (B) code (but is not necessarily tracked), otherwise does 〈false〉.

`\TrackLangIfKnownIsoTwoLetterLang``{〈language〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Does 〈true〉 if 〈language〉 has an ISO 639-1 code (but is not necessarily tracked), otherwise does 〈false〉.

`\TrackLangIfKnownLang``{〈language〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Does 〈true〉 if 〈language〉 is known (but not necessarily tracked), otherwise does 〈false〉.

`\TrackLangIfKnownLangFromIso``{〈ISO code〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Does 〈true〉 if the given language code (639-1 or 639-2 or 639-3) is recognised (but not necessarily tracked), otherwise does 〈false〉.

`\TrackLangIfKnownNumericRegion``{〈numeric code〉}{〈true〉}{〈false〉}`tracklang-region-codes.tex v1.3+

Expands to 〈true〉 if there’s a known mapping for the given numeric region code, otherwise expands to 〈false〉. §4; 30

`\TrackLangIfLanguageTag``{〈tag〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Does 〈true〉 if the argument is a language tag otherwise does 〈false〉.

`\TrackLangIfRegionTag``{〈tag〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Does 〈true〉 if the argument is a region tag otherwise does 〈false〉.

`\TrackLangIfScriptTag``{〈tag〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Does 〈true〉 if the argument is a script tag otherwise does 〈false〉.

`\TrackLangIfVariantTag``{〈tag〉}{〈true〉}{〈false〉}`tracklang.tex v1.3+

Does 〈true〉 if the argument is a variant tag otherwise does 〈false〉.

`\TrackLangLastTrackedDialect` tracklang.tex v1.3+

Expands to the label of the last tracked dialect. §6.5; 77

`\TrackLangNewLanguage``{〈language label〉}{〈639-1 code〉}{〈639-2 (T)〉}{〈639-2 (B)〉}{〈639-3〉}{〈3166-1〉}{〈default script〉}`tracklang.tex v1.3+

Identifies a new language that may be tracked. Apart from 〈language label〉, the other arguments may be empty if the information is unavailable. §6.5; 76

`\TrackLangNumericToAlphaIIIRegion``{〈numeric code〉}`tracklang-region-codes.tex v1.3+

Expands to the alpha-3 code corresponding to the given numeric code. §4; 31

`\TrackLangNumericToAlphaIIRegion``{〈numeric code〉}`tracklang-region-codes.tex v1.3+

Expands to the alpha-2 code corresponding to the given numeric code. §4; 30

`\TrackLangParseFromEnv` tracklang.tex v1.3+

Attempts to obtain locale information from the expansion of `\TrackLangEnv`. §3; 27

`\TrackLangProvidePredefinedDialect``{〈dialect label〉}{〈root language label〉}{〈3166-1 code〉}{〈modifier〉}{〈variant〉}{〈map〉}{〈script〉}`tracklang.tex v1.4+

Defines a predefined dialect label that can be used by `\TrackPredefinedDialect`. §6.6; 77

`\TrackLangProvidePredefinedLanguage``{〈language label〉}`tracklang.tex v1.4+

Sets up a language label for use with `\TrackPredefinedDialect`. §6.6; 77

`\TrackLangProvidesResource``{〈tag〉}[〈version info〉]`tracklang.tex v1.3+

Analogous to `\ProvidesFile`. §5; 53

`\TrackLangQueryEnv` tracklang.tex v1.3+

Attempts to obtain locale information from the `LC_ALL` environment variable via the shell escape or, with LuaTeX, `\directlua`. §3; 26

`\TrackLangQueryOtherEnv``{〈env-name〉}`tracklang.tex v1.3+

Attempts to obtain locale information from the `LC_ALL` environment variable and then by the 〈env-name〉 environment variable via the shell escape or, with LuaTeX, `\directlua`. §3; 27

`\TrackLangRedefHook``{〈code〉}{〈type〉}`tracklang.tex v1.4+

Similar to `\TrackLangAddToHook` but redefines the hook rather than appending to it. §5; 56

`\TrackLangRegionMap``{〈numeric〉}{〈alpha-2〉}{〈alpha-3〉}`tracklang-region-codes.tex v1.3+

Establishes a mapping between a numeric region code and alpha-2 and alpha-3 codes. §4; 31

`\TrackLangRequestResource``{〈tag〉}{〈not found code〉}`tracklang.tex v1.3+

As `\TrackLangRequireResource` but does 〈not found code〉 if the file doesn’t exist. §5; 54

`\TrackLangRequireDialect``[〈load code〉]{〈pkgname〉}{〈dialect〉}`tracklang.tex v1.3+

Loads the dialect for the given package using `\IfTrackedLanguageFileExists`. §5; 46

`\TrackLangRequireDialectOmitDialectLabel``[〈load code〉]{〈pkgname〉}{〈dialect〉}`tracklang.tex v1.3+

Loads the dialect for the given package using `\IfTrackedLanguageFileExistsOmitDialectLabel`. §5; 46

`\TrackLangRequireDialectOmitDialectLabelOmitOnlyRegion``[〈load code〉]{〈pkgname〉}{〈dialect〉}`tracklang.tex v1.3+

Loads the dialect for the given package using `\IfTrackedLanguageFileExistsOmitDialectLabelOmitOnlyRegion`. §5; 46

`\TrackLangRequireDialectOmitOnlyRegion``[〈load code〉]{〈pkgname〉}{〈dialect〉}`tracklang.tex v1.3+

Loads the dialect for the given package using `\IfTrackedLanguageFileExistsOmitOnlyRegion`. §5; 46

`\TrackLangRequireDialectPrefix` tracklang.tex v1.3+

Defined by `\TrackLangRequireDialect`. §5; 46

`\TrackLangRequireResource``{〈tag〉}`tracklang.tex v1.3+

Loads the appropriate ldf file if it hasn’t already been loaded. §5; 54

`\TrackLangRequireResourceOrDo``{〈tag〉}{〈code1〉}{〈code2〉}`tracklang.tex v1.3+

As `\TrackLangRequireResource` but does 〈code1〉 if the file is now loaded or 〈code2〉 if the file has already been loaded. §5; 54

`\TrackLangScriptAlphaToDir``{〈alpha code〉}`tracklang-scripts.tex v1.3+

Expands to the direction associated with the given alpha script code. §4; 32

`\TrackLangScriptAlphaToName``{〈alpha code〉}`tracklang-scripts.tex v1.3+

Expands to the name associated with the given alpha script code. §4; 32

`\TrackLangScriptAlphaToNumeric``{〈alpha code〉}`tracklang-scripts.tex v1.3+

Expands to the numeric script code corresponding to the given alpha code. §4; 32

`\TrackLangScript〈Code〉`tracklang-scripts.tex v1.3+

Set by `\TrackLangScriptMap` to the associated alpha code 〈Code〉. §4; 32

`\TrackLangScriptGetParent``{〈alpha code〉}`tracklang-scripts.tex v1.3+

Expands to the parent of the given alpha script code. §4; 33

`\TrackLangScriptIfHasParent``{〈alpha code〉}{〈true〉}{〈false〉}`tracklang-scripts.tex v1.3+

Expands to 〈true〉 if the given alpha script code has a parent otherwise expands to 〈false〉. §4; 33

`\TrackLangScriptIfKnownAlpha``{〈alpha code〉}{〈true〉}{〈false〉}`tracklang-scripts.tex v1.3+

Expands to 〈true〉 if there’s a known mapping for the given alpha script code otherwise expands to 〈false〉. §4; 32

`\TrackLangScriptIfKnownNumeric``{〈numeric code〉}{〈true〉}{〈false〉}`tracklang-scripts.tex v1.3+

Expands to 〈true〉 if there’s a known mapping for the given numeric script code otherwise expands to 〈false〉. §4; 32

`\TrackLangScriptMap``{〈letter code〉}{〈numeric code〉}{〈script name〉}{〈direction〉}{〈parent script〉}`tracklang-scripts.tex v1.3+

Defines a mapping between an alpha code and a numeric code. §4; 32

`\TrackLangScriptNumericToAlpha``{〈numeric code〉}`tracklang-scripts.tex v1.3+

Expands to the alpha script code corresponding to the given numeric code. §4; 32

`\TrackLangScriptSetParent``{〈alpha code〉}{〈parent alpha code〉}`tracklang-scripts.tex v1.3+

Sets the parent for the given alpha script code. §4; 33

`\TrackLangShowWarningsfalse` tracklang.tex v1.3+

Sets `\ifTrackLangShowWarnings` to false. §3; 24

`\TrackLangShowWarningstrue` tracklang.tex v1.3+

Sets `\ifTrackLangShowWarnings` to true. §3; 24

`\TrackLanguageTag``{〈tag〉}`tracklang.tex v1.3+

Parse 〈tag〉, which should be a regular, well-formed RFC 5646 language tag (not an irregular grandfather tag) and track the dialect. Note that the tag must start with a language identifier and can’t simply be a region code. §3; 21

`\TrackLocale``{〈locale〉}`tracklang.tex v1.3+

Tracks the dialect identified by the given 〈locale〉, which may either be a predefined language/dialect or in the same format as `\TrackLangEnv`. §3; 20

`\TrackPredefinedDialect``{〈dialect label〉}`tracklang.tex v1.0+

Tracks a predefined language or dialect. §3; 20

`\TwoLetterIsoCountryCode` tracklang.tex v1.0+

Expands to 3166-1 (should not be redefined). §5; 40

`\TwoLetterIsoLanguageCode` tracklang.tex v1.0+

Expands to 639-1 (should not be redefined). §5; 40

[top]

# Package Option Summary[link]

〈dialect〉𝍢

Any dialect label listed in Table 1.1 may be used as a package option.

〈iso-tag〉𝍢

Any ISO tag listed in Table 1.1 may be used as a package option.

noverbose 𝍢 tracklang v1.6.3+

Switches off verbose setting (default). §3; 19

nowarn 𝍢 tracklang v1.6.5+

Switches off warning setting. §3; 19

verbose 𝍢 tracklang v1.6.3+

Switches on verbose setting. §3; 19

warn 𝍢 tracklang v1.6.5+

Switches on warning setting (default). §3; 19

[top]

# Index[link]

Symbols @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
[top]

## Symbols[link]

`_` (separator) 20, 24, 25, 79, 81
`.` (code-set) 20, 24, 25, 79
`\\` (escaped backslash) 26
`$` (environment variable) 26
`-` (separator) 20, 25
--shell-escape 23, 24
[top]

## @[link]

`@` (catcode 11) 19
`@` (modifier) 20, 79
`\@for` 37, 95
`\@nil` 38
`\@tracklang@declareoption` §3; 19, 95
`\@tracklang@for` §5; 37, 95
`\@tracklang@prelangpkgcheck@hook` §6; 72, 95
[top]

## A[link]

aa (ISO code)
see afar
ab (ISO code)
see abkhaz
abkhaz (root language) §1; Table 1.2
acadian (option) §1; Table 1.3
AD (region) §A; Table A.1
`\AddTrackedCountryIsoCode` 95
`\AddTrackedDialect` §6.5; 76, 77–80, 95, 96
`\AddTrackedIsoLanguage` 80, 96
`\AddTrackedLanguage` §6.5; 76, 96
`\AddTrackedLanguageIsoCodes` §6.6; 78, 79, 80, 96
Adlm (script) §A; Table A.2
AE (region) §A; Table A.1
ae (ISO code)
see avestan
AF (region) §A; Table A.1
af (ISO code)
see afrikaans
Afak (script) §A; Table A.2
afar (root language) §1; Table 1.2
afrikaans (root language) §1; Table 1.2
AG (region) §A; Table A.1
Aghb (script) §A; Table A.2
Ahom (script) §A; Table A.2
AI (region) §A; Table A.1
ak (ISO code)
see akan
akan (root language) §1; Table 1.2
AL (region) §A; Table A.1
albanian (root language) §1; Table 1.2
alien.sty 80–82
alien package
see alien.sty
AM (region) §A; Table A.1
am (ISO code)
see amharic
american (option) §1; Table 1.3; 60, 62, 71
amharic (root language) §1; Table 1.2
an (ISO code)
see aragonese
ang (ISO code)
see anglosaxon
anglosaxon (root language) §1; Table 1.2
animals.sty 56
`\AnyTrackedLanguages` §5; 14, 15, 35, 96
`\AnyTrackedRegions` §5; 36, 96
AO (region) §A; Table A.1
apa (ISO code)
see apache
apache (root language) §1; Table 1.2
AQ (region) §A; Table A.1
AR (region) §A; Table A.1
ar (ISO code)
see arabic
Arab (script) §A; Table A.2
arabic (root language) §1; Table 1.2
aragonese (root language) §1; Table 1.2
Aran (script) §A; Table A.2
argentinespanish (option) §1; Table 1.3
armenian (root language) §1; Table 1.2
Armi (script) §A; Table A.2
Armn (script) §A; Table A.2
AS (region) §A; Table A.1
as (ISO code)
see assamese
assamese (root language) §1; Table 1.2
ast (ISO code)
see asturian
asturian (root language) §1; Table 1.2
AT (region) §A; Table A.1
`\AtBeginDocument` 38
AU (region) §A; Table A.1
australian (option) §1; Table 1.3
austrian (option) §1; Table 1.3
av (ISO code)
see avaric
avaric (root language) §1; Table 1.2
avestan (root language) §1; Table 1.2
Avst (script) §A; Table A.2
AW (region) §A; Table A.1
AX (region) §A; Table A.1
ay (ISO code)
see aymara
aymara (root language) §1; Table 1.2
AZ (region) §A; Table A.1
az (ISO code)
see azerbaijani
azerbaijani (root language) §1; Table 1.2
[top]

## B[link]

BA (region) §A; Table A.1
ba (ISO code)
see bashkir
babel package a, 2, 3, 9, 12, 13, 35, 55, 59, 60, 69, 71, 78, 95
`\babelprovide` 2, 12
bahasa (option) §1; Table 1.3
bahasai (root language) §1; Table 1.2
bahasam (root language) §1; Table 1.2
Bali (script) §A; Table A.2
bambara (root language) §1; Table 1.2
Bamu (script) §A; Table A.2
bashkir (root language) §1; Table 1.2
basque (root language) §1; Table 1.2
Bass (script) §A; Table A.2
Batk (script) §A; Table A.2
BB (region) §A; Table A.1
`\bbl@loaded` 35
BCP 47 35
BD (region) §A; Table A.1
BE (region) §A; Table A.1
be (ISO code)
see belarusian
belarusian (root language) §1; Table 1.2
belgiangerman (option) §1; Table 1.3
belgique (option) §1; Table 1.3
Beng (script) §A; Table A.2
bengali (root language) §1; Table 1.2
ber (ISO code)
see berber
berber (root language) §1; Table 1.2
BF (region) §A; Table A.1
BG (region) §A; Table A.1
bg (ISO code)
see bulgarian
BH (region) §A; Table A.1
bh (ISO code)
see bihari
BI (region) §A; Table A.1
bi (ISO code)
see bislama
bihari (root language) §1; Table 1.2
bislama (root language) §1; Table 1.2
BJ (region) §A; Table A.1
BL (region) §A; Table A.1
Blis (script) §A; Table A.2
BM (region) §A; Table A.1
bm (ISO code)
see bambara
BN (region) §A; Table A.1
bn (ISO code)
see bengali
BO (region) §A; Table A.1
bo (ISO code)
see tibetan
bokmal (root language) §1; Table 1.2
bolivianspanish (option) §1; Table 1.3
Bopo (script) §A; Table A.2
bosnian (root language) §1; Table 1.2
BQ (region) §A; Table A.1
BR (region) §A; Table A.1
br (ISO code)
see breton
Brah (script) §A; Table A.2
Brai (script) §A; Table A.2
brazil (option) §1; Table 1.3
brazilian (option) §1; Table 1.3; 21
breton (root language) §1; Table 1.2
british (option) §1; Table 1.3; 2, 3, 12, 13, 15, 17, 18, 34, 36, 50, 55, 61–63, 71
BS (region) §A; Table A.1
bs (ISO code)
see bosnian
BT (region) §A; Table A.1
Bugi (script) §A; Table A.2
Buhd (script) §A; Table A.2
bulgarian (root language) §1; Table 1.2
burmese (root language) §1; Table 1.2
BV (region) §A; Table A.1
BW (region) §A; Table A.1
BY (region) §A; Table A.1
BZ (region) §A; Table A.1
[top]

## C[link]

CA (region) §A; Table A.1
ca (ISO code)
see catalan
Cakm (script) §A; Table A.2
canadian (option) §1; Table 1.3
canadien (option) §1; Table 1.3; 12
Cans (script) §A; Table A.2
`\captions〈dialect〉` Table 1.3; 13, 16, 55, 56, 61, 62, 69, 71, 74, 78, 81, 102
Cari (script) §A; Table A.2
catalan (root language) §1; Table 1.2
CC (region) §A; Table A.1
CD (region) §A; Table A.1
ce (ISO code)
see chechen
CF (region) §A; Table A.1
CG (region) §A; Table A.1
CH (region) §A; Table A.1
ch (ISO code)
see chamorro
Cham (script) §A; Table A.2
chamorro (root language) §1; Table 1.2
chechen (root language) §1; Table 1.2
Cher (script) §A; Table A.2
chichewa (root language) §1; Table 1.2
chilianspanish (option) §1; Table 1.3
chinese (root language) §1; Table 1.2; 22, 80
churchslavonic (root language) §1; Table 1.2
chuvash (root language) §1; Table 1.2
CI (region) §A; Table A.1
Cirt (script) §A; Table A.2
CK (region) §A; Table A.1
CL (region) §A; Table A.1
CLI 94
CM (region) §A; Table A.1
CN (region) §A; Table A.1
CO (region) §A; Table A.1
co (ISO code)
see corsican
code-set 20, 26, 106
columbianspanish (option) §1; Table 1.3
cop (ISO code)
see coptic
Copt (script) §A; Table A.2
coptic (root language) §1; Table 1.2
cornish (root language) §1; Table 1.2
corsican (root language) §1; Table 1.2
costaricanspanish (option) §1; Table 1.3
Cprt (script) §A; Table A.2
CR (region) §A; Table A.1
cr (ISO code)
see cree
cree (root language) §1; Table 1.2
croatia (option) §1; Table 1.3
croatian (root language) §1; Table 1.2
cs (ISO code)
see czech
CU (region) §A; Table A.1
cu (ISO code)
see churchslavonic
cubanspanish (option) §1; Table 1.3
`\CurrentTrackedDialect` §5; 10, 47, 55, 74, 81, 96
`\CurrentTrackedDialectAdditional` §5; 11, 47, 96
`\CurrentTrackedDialectModifier` §5; 11, 47, 74, 97
`\CurrentTrackedDialectScript` §5; 11, 16, 48, 74, 97
`\CurrentTrackedDialectSubLang` §5; 11, 47, 75, 97
`\CurrentTrackedDialectVariant` §5; 11, 47, 74, 97
`\CurrentTrackedIsoCode` §5; 11, 47, 75, 97
`\CurrentTrackedLanguage` §5; 11, 47, 50, 55, 74, 97
`\CurrentTrackedLanguageTag` §5; 11, 47, 48, 75, 97
`\CurrentTrackedRegion` §5; 11, 47, 69, 75, 97
`\CurrentTrackedTag` §5; 45, 48, 69, 98, 101
CV (region) §A; Table A.1
cv (ISO code)
see chuvash
CW (region) §A; Table A.1
CX (region) §A; Table A.1
cy-GB (option) §1; Table 1.1
CY (region) §A; Table A.1
cy (ISO code)
see welsh
cymraeg (option) §1; Table 1.3
Cyrl (script) §A; Table A.2; 16, 32, 43, 79
Cyrs (script) §A; Table A.2
CZ (region) §A; Table A.1
czech (root language) §1; Table 1.2
[top]

## D[link]

da (ISO code)
see danish
danish (root language) §1; Table 1.2
`\date〈dialect〉` Table 1.3; 16, 56
datetime2 package 9, 21, 22
de-AT (option) §1; Table 1.1
de-AT-1996 (option) §1; Table 1.1
de-BE (option) §1; Table 1.1
de-CH (option) §1; Table 1.1
de-CH-1996 (option) §1; Table 1.1
de-DE (option) §1; Table 1.1
de-DE-1996 (option) §1; Table 1.1
DE (region) §A; Table A.1
de (ISO code)
see german
`\DeclareOption` 14, 19
deutsch (option) §1; Table 1.3
Deva (script) §A; Table A.2
〈dialect〉 115
`\directlua` a, 23, 110, 111
divehi (root language) §1; Table 1.2
DJ (region) §A; Table A.1
DK (region) §A; Table A.1
DM (region) §A; Table A.1
DO (region) §A; Table A.1
dominicanspanish (option) §1; Table 1.3
dsb (ISO code)
see lsorbian
Dsrt (script) §A; Table A.2
Dupl (script) §A; Table A.2
dutch (root language) §1; Table 1.2
dv (ISO code)
see divehi
DZ (region) §A; Table A.1
dz (ISO code)
see dzongkha
dzongkha (root language) §1; Table 1.2
[top]

## E[link]

easternpunjabi (root language) §1; Table 1.2
EC (region) §A; Table A.1
ecudorianspanish (option) §1; Table 1.3
EE (region) §A; Table A.1
ee (ISO code)
see ewe
EG (region) §A; Table A.1
Egyd (script) §A; Table A.2
Egyh (script) §A; Table A.2
Egyp (script) §A; Table A.2
EH (region) §A; Table A.1
el (ISO code)
see greek
Elba (script) §A; Table A.2
elsalvadorspanish (option) §1; Table 1.3
en-AU (option) §1; Table 1.1
en-CA (option) §1; Table 1.1
en-GB (option) §1; Table 1.1; 12, 15, 25
en-GG (option) §1; Table 1.1
en-IE (option) §1; Table 1.1; 12
en-IM (option) §1; Table 1.1
en-JE (option) §1; Table 1.1
en-MT (option) §1; Table 1.1; 13, 17, 71
en-NZ (option) §1; Table 1.1
en-US (option) §1; Table 1.1
en (ISO code)
see english
english (root language) §1; Table 1.2; 2, 3, 15, 34, 36, 39
environment variables
`LANG` a, 23–26, 81
`LC_ALL` a, 23, 26, 105, 110, 111
`LC_MONETARY` 27
eo (ISO code)
see esperanto
ER (region) §A; Table A.1
es-AR (option) §1; Table 1.1
es-BO (option) §1; Table 1.1
es-CL (option) §1; Table 1.1
es-CO (option) §1; Table 1.1
es-CR (option) §1; Table 1.1
es-CU (option) §1; Table 1.1
es-DO (option) §1; Table 1.1
es-EC (option) §1; Table 1.1
es-ES (option) §1; Table 1.1
es-GT (option) §1; Table 1.1
es-HN (option) §1; Table 1.1
es-MX (option) §1; Table 1.1
es-NI (option) §1; Table 1.1
es-PA (option) §1; Table 1.1
es-PE (option) §1; Table 1.1
es-PR (option) §1; Table 1.1
es-PY (option) §1; Table 1.1
es-SV (option) §1; Table 1.1
es-UY (option) §1; Table 1.1
es-VE (option) §1; Table 1.1
ES (region) §A; Table A.1
es (ISO code)
see spanish
esperanto (root language) §1; Table 1.2
estonian (root language) §1; Table 1.2
ET (region) §A; Table A.1
et (ISO code)
see estonian
etex (application) 23
Ethi (script) §A; Table A.2
etoolbox package 55
eu (ISO code)
see basque
ewe (root language) §1; Table 1.2
[top]

## F[link]

fa (ISO code)
see farsi
faroese (root language) §1; Table 1.2
farsi (root language) §1; Table 1.2
ff (ISO code)
see fula
FI (region) §A; Table A.1
fi (ISO code)
see finnish
fijian (root language) §1; Table 1.2
file formats
ldf 13, 15, 46, 63
log 94
tex 9
finnish (root language) §1; Table 1.2
FJ (region) §A; Table A.1
fj (ISO code)
see fijian
FK (region) §A; Table A.1
flemish (option) §1; Table 1.3
FM (region) §A; Table A.1
FO (region) §A; Table A.1
fo (ISO code)
see faroese
`\ForEachTrackedDialect` §5; 2, 15, 37, 98
`\ForEachTrackedLanguage` §5; 37, 98
`\ForEachTrackedRegion` §5; 37, 98
fr-BE (option) §1; Table 1.1
fr-CA (option) §1; Table 1.1
fr-CH (option) §1; Table 1.1
fr-FR (option) §1; Table 1.1
fr-GG (option) §1; Table 1.1
fr-JE (option) §1; Table 1.1
FR (region) §A; Table A.1
fr (ISO code)
see french
francais (option) §1; Table 1.3; 52
france (option) §1; Table 1.3
french (root language) §1; Table 1.2; 52
frenchb (option) §1; Table 1.3
friulan (root language) §1; Table 1.2
friulano (option) §1; Table 1.3
friulian (option) §1; Table 1.3
fula (root language) §1; Table 1.2
fur (ISO code)
see friulan
furlan (option) §1; Table 1.3
fy (ISO code)
see westernfrisian
[top]

## G[link]

ga-GB (option) §1; Table 1.1
ga-IE (option) §1; Table 1.1; 12
GA (region) §A; Table A.1
ga (ISO code)
see irish
gaeilge (option) §1; Table 1.3
gaelic (option) §1; Table 1.3
galician (root language) §1; Table 1.2
galicien (option) §1; Table 1.3
ganda (root language) §1; Table 1.2
GB (region) §A; Table A.1; 36, 39
GBirish (option) §1; Table 1.3
GBscottish (option) §1; Table 1.3
GBwelsh (option) §1; Table 1.3
gd-GB (option) §1; Table 1.1
GD (region) §A; Table A.1
gd (ISO code)
see scottish
GE (region) §A; Table A.1
Geok (script) §A; Table A.2
Geor (script) §A; Table A.2
georgian (root language) §1; Table 1.2
german (root language) §1; Table 1.2; 35, 78
german package 35
germanb (option) §1; Table 1.3
germanDE (option) §1; Table 1.3
`\GetTrackedDialectAdditional` §5; 44, 75, 98
`\GetTrackedDialectFromLanguageTag` §5; 36, 98, 103
`\GetTrackedDialectModifier` §5; 41, 99
`\GetTrackedDialectScript` §5; 42, 75, 99
`\GetTrackedDialectSubLang` §5; 44, 99
`\GetTrackedDialectVariant` §5; 42, 99
`\GetTrackedLanguageTag` §5; Table 1.2, Table 1.3; 40, 99
GF (region) §A; Table A.1
GG (region) §A; Table A.1
GH (region) §A; Table A.1
GI (region) §A; Table A.1
GL (region) §A; Table A.1
gl (ISO code)
see galician
Glag (script) §A; Table A.2
glossaries package 2, 9
GM (region) §A; Table A.1
GN (region) §A; Table A.1
gn (ISO code)
see guarani
Goth (script) §A; Table A.2
GP (region) §A; Table A.1
GQ (region) §A; Table A.1
GR (region) §A; Table A.1
Gran (script) §A; Table A.2
greek (root language) §1; Table 1.2
Grek (script) §A; Table A.2
GS (region) §A; Table A.1
GT (region) §A; Table A.1
GU (region) §A; Table A.1
gu (ISO code)
see gujarati
guarani (root language) §1; Table 1.2
guatemalanspanish (option) §1; Table 1.3
guernseyenglish (option) §1; Table 1.3
guernseyfrench (option) §1; Table 1.3
gujarati (root language) §1; Table 1.2
Gujr (script) §A; Table A.2
Guru (script) §A; Table A.2
gv (ISO code)
see manx
GW (region) §A; Table A.1
GY (region) §A; Table A.1
[top]

## H[link]

ha (ISO code)
see hausa
haitian (root language) §1; Table 1.2
Hanb (script) §A; Table A.2
Hang (script) §A; Table A.2
Hani (script) §A; Table A.2
Hano (script) §A; Table A.2
Hans (script) §A; Table A.2
Hant (script) §A; Table A.2
Hatr (script) §A; Table A.2
hausa (root language) §1; Table 1.2
he (ISO code)
see hebrew
Hebr (script) §A; Table A.2
hebrew (root language) §1; Table 1.2
herero (root language) §1; Table 1.2
hi (ISO code)
see hindi
hindi (root language) §1; Table 1.2
Hira (script) §A; Table A.2
hirimotu (root language) §1; Table 1.2
HK (region) §A; Table A.1
Hluw (script) §A; Table A.2
HM (region) §A; Table A.1
Hmng (script) §A; Table A.2
HN (region) §A; Table A.1
ho (ISO code)
see hirimotu
honduranspanish (option) §1; Table 1.3
hr-HR (option) §1; Table 1.1
HR (region) §A; Table A.1
hr (ISO code)
see croatian
Hrkt (script) §A; Table A.2
hsb (ISO code)
see usorbian
HT (region) §A; Table A.1
ht (ISO code)
see haitian
hu-HU (option) §1; Table 1.1
HU (region) §A; Table A.1
hu (ISO code)
see magyar
Hung (script) §A; Table A.2
hungarian (option) §1; Table 1.3
hy (ISO code)
see armenian
hz (ISO code)
see herero
[top]

## I[link]

ia (ISO code)
see interlingua
icelandic (root language) §1; Table 1.2
id-IN (option) §1; Table 1.1
ID (region) §A; Table A.1
id (ISO code)
see bahasai
ido (root language) §1; Table 1.2
IE (region) §A; Table A.1
ie (ISO code)
see interlingue
IEenglish (option) §1; Table 1.3
IEirish (option) §1; Table 1.3
`\IfHasTrackedDialectAdditional` §5; 44, 99
`\IfHasTrackedDialectModifier` §5; 41, 99
`\IfHasTrackedDialectScript` §5; 43, 100
`\IfHasTrackedDialectSubLang` §5; 44, 100
`\IfHasTrackedDialectVariant` §5; 42, 100
`\IfTrackedDialect` §5; 38, 100
`\IfTrackedDialectIsScriptCs` §5; 32, 43, 100
`\IfTrackedIsoCode` §5; 39, 100
`\IfTrackedLanguage` §5; 38, 100
`\IfTrackedLanguageFileExists` §5; 15, 45, 46, 48, 55, 62, 101, 111
`\IfTrackedLanguageFileExistsOmitDialectLabel` §5; 45, 46, 48, 101, 111
`\IfTrackedLanguageFileExistsOmitDialectLabelOmitOnlyRegion` §5; 45, 46, 48, 49, 101, 111
`\IfTrackedLanguageFileExistsOmitOnlyRegion` §5; 45, 46, 49, 101, 112
`\IfTrackedLanguageHasIsoCode` §5; 39, 101
`\ifTrackLangShowInfo` 102
`\ifTrackLangShowVerbose` 102
`\ifTrackLangShowWarnings` 102, 114
ig (ISO code)
see igbo
igbo (root language) §1; Table 1.2
ii (ISO code)
see nuosu
ik (ISO code)
see inupiaq
IL (region) §A; Table A.1
IM (region) §A; Table A.1
IN (region) §A; Table A.1
indon (option) §1; Table 1.3
indonesian (option) §1; Table 1.3
Inds (script) §A; Table A.2
`\input` 9–11, 13, 17, 19, 26, 72, 73, 82
inputenc package 54
`\inputencodingname` 54, 105
`\InputIfFileExists` 54
interlingua (root language) §1; Table 1.2
interlingue (root language) §1; Table 1.2
inuktitut (root language) §1; Table 1.2
inupiaq (root language) §1; Table 1.2
IO (region) §A; Table A.1
io (ISO code)
see ido
IQ (region) §A; Table A.1
IR (region) §A; Table A.1
irish (root language) §1; Table 1.2
IS (region) §A; Table A.1
is (ISO code)
see icelandic
isleofmanenglish (option) §1; Table 1.3
〈iso-tag〉 115
ISO (International Organization for Standardization) Table 1.1; b, 15, 39
ISO 15924 31, 43, 73, 77, 79
ISO 3166-1 20, 23, 35, 39, 40, 47, 73, 75–77, 95, 97, 106, 107, 114
ISO 639-1 20, 22, 35, 39, 40, 47, 51, 52, 62, 73, 75, 76, 82, 96, 97, 107, 108, 114
ISO 639-2 20, 35, 40, 47, 51, 52, 62, 75, 76, 82, 96, 97, 103, 106–108
ISO 639-2 (B) 21, 35, 76, 107, 108
ISO 639-2 (T) 21, 35, 76
ISO 639-3 22, 39, 40, 47, 48, 75, 76, 96, 97, 103, 107, 108
istriacountycroatian (option) §1; Table 1.3
istriacountyitalian (option) §1; Table 1.3
it-CH (option) §1; Table 1.1
it-HR (option) §1; Table 1.1
it-IT (option) §1; Table 1.1
it-SI (option) §1; Table 1.1
it-SM (option) §1; Table 1.1
it-VA (option) §1; Table 1.1
IT (region) §A; Table A.1
it (ISO code)
see italian
Ital (script) §A; Table A.2
italian (root language) §1; Table 1.2
italy (option) §1; Table 1.3
iu (ISO code)
see inuktitut
[top]

## J[link]

ja (ISO code)
see japanese
Jamo (script) §A; Table A.2
japanese (root language) §1; Table 1.2
Java (script) §A; Table A.2
javanese (root language) §1; Table 1.2
JE (region) §A; Table A.1
jerseyenglish (option) §1; Table 1.3
jerseyfrench (option) §1; Table 1.3
JM (region) §A; Table A.1
JO (region) §A; Table A.1
JP (region) §A; Table A.1
Jpan (script) §A; Table A.2
Jurc (script) §A; Table A.2
jv (ISO code)
see javanese
[top]

## K[link]

ka (ISO code)
see georgian
kalaallisut (root language) §1; Table 1.2
Kali (script) §A; Table A.2
Kana (script) §A; Table A.2
kannada (root language) §1; Table 1.2
kanuri (root language) §1; Table 1.2
kashmiri (root language) §1; Table 1.2
kazakh (root language) §1; Table 1.2
KE (region) §A; Table A.1
KG (region) §A; Table A.1
kg (ISO code)
see kongo
KH (region) §A; Table A.1
Khar (script) §A; Table A.2
khmer (root language) §1; Table 1.2
Khmr (script) §A; Table A.2
Khoj (script) §A; Table A.2
KI (region) §A; Table A.1
ki (ISO code)
see kikuyu
kikuyu (root language) §1; Table 1.2
kinyarwanda (root language) §1; Table 1.2
kirundi (root language) §1; Table 1.2
Kitl (script) §A; Table A.2
Kits (script) §A; Table A.2
kj (ISO code)
see kwanyama
kk (ISO code)
see kazakh
kl (ISO code)
see kalaallisut
KM (region) §A; Table A.1
km (ISO code)
see khmer
KN (region) §A; Table A.1
kn (ISO code)
see kannada
Knda (script) §A; Table A.2
ko (ISO code)
see korean
komi (root language) §1; Table 1.2
kongo (root language) §1; Table 1.2
Kore (script) §A; Table A.2
korean (root language) §1; Table 1.2
KP (region) §A; Table A.1
Kpel (script) §A; Table A.2
kpsewhich (application)
KR (region) §A; Table A.1
kr (ISO code)
see kanuri
ks (ISO code)
see kashmiri
Kthi (script) §A; Table A.2
ku (ISO code)
see kurdish
kurdish (root language) §1; Table 1.2
kurmanji (option) §1; Table 1.3
kv (ISO code)
see komi
KW (region) §A; Table A.1
kw (ISO code)
see cornish
kwanyama (root language) §1; Table 1.2
KY (region) §A; Table A.1
ky (ISO code)
see kyrgyz
kyrgyz (root language) §1; Table 1.2
KZ (region) §A; Table A.1
[top]

## L[link]

LA (region) §A; Table A.1
la (ISO code)
see latin
Lana (script) §A; Table A.2
`\languagename` 10, 75
lao (root language) §1; Table 1.2
Laoo (script) §A; Table A.2
latein (option) §1; Table 1.3
Latf (script) §A; Table A.2
Latg (script) §A; Table A.2
latin (root language) §1; Table 1.2
Latn (script) §A; Table A.2; 10, 11, 16, 32, 36, 43, 52, 75, 79, 82
latvian (root language) §1; Table 1.2
LB (region) §A; Table A.1
lb (ISO code)
see luxembourgish
LC (region) §A; Table A.1
Leke (script) §A; Table A.2
Lepc (script) §A; Table A.2
lg (ISO code)
see ganda
LI (region) §A; Table A.1
li (ISO code)
see limburgish
Limb (script) §A; Table A.2
limburgish (root language) §1; Table 1.2
Lina (script) §A; Table A.2
Linb (script) §A; Table A.2
lingala (root language) §1; Table 1.2
Lisu (script) §A; Table A.2
lithuanian (root language) §1; Table 1.2
LK (region) §A; Table A.1
ln (ISO code)
see lingala
lo (ISO code)
see lao
`\LocaleForEach` 2, 12, 35
Loma (script) §A; Table A.2
lowersorbian (option) §1; Table 1.3
LR (region) §A; Table A.1
LS (region) §A; Table A.1
lsorbian (root language) §1; Table 1.2
LT (region) §A; Table A.1
lt (ISO code)
see lithuanian
LU (region) §A; Table A.1
lu (ISO code)
see lubakatanga
lubakatanga (root language) §1; Table 1.2
luxembourgish (root language) §1; Table 1.2
LV (region) §A; Table A.1
lv (ISO code)
see latvian
LY (region) §A; Table A.1
Lyci (script) §A; Table A.2
Lydi (script) §A; Table A.2
[top]

## M[link]

MA (region) §A; Table A.1
macedonian (root language) §1; Table 1.2
magyar (root language) §1; Table 1.2
Mahj (script) §A; Table A.2
malagasy (root language) §1; Table 1.2
malay (option) §1; Table 1.3
malayalam (root language) §1; Table 1.2
maltaenglish (option) §1; Table 1.3; 13, 18
maltamaltese (option) §1; Table 1.3
maltese (root language) §1; Table 1.2
Mand (script) §A; Table A.2
Mani (script) §A; Table A.2
manx (root language) §1; Table 1.2; 68, 69
maori (root language) §1; Table 1.2
marathi (root language) §1; Table 1.2
Marc (script) §A; Table A.2
marshallese (root language) §1; Table 1.2
Maya (script) §A; Table A.2
MC (region) §A; Table A.1
MD (region) §A; Table A.1
ME (region) §A; Table A.1
Mend (script) §A; Table A.2
Merc (script) §A; Table A.2
Mero (script) §A; Table A.2
mexicanspanish (option) §1; Table 1.3; 3
meyalu (option) §1; Table 1.3
MF (region) §A; Table A.1
MG (region) §A; Table A.1
mg (ISO code)
see malagasy
MH (region) §A; Table A.1
mh (ISO code)
see marshallese
mi (ISO code)
see maori
MK (region) §A; Table A.1
mk (ISO code)
see macedonian
ML (region) §A; Table A.1
ml (ISO code)
see malayalam
Mlym (script) §A; Table A.2
MM (region) §A; Table A.1
MN (region) §A; Table A.1
mn (ISO code)
see mongolian
MO (region) §A; Table A.1
Modi (script) §A; Table A.2
modifier 20, 26, 34, 36, 41, 77, 79, 106
Mong (script) §A; Table A.2
mongolian (root language) §1; Table 1.2
Moon (script) §A; Table A.2
MP (region) §A; Table A.1
MQ (region) §A; Table A.1
MR (region) §A; Table A.1
mr (ISO code)
see marathi
Mroo (script) §A; Table A.2
ms-MY (option) §1; Table 1.1
MS (region) §A; Table A.1
ms (ISO code)
see bahasam
mt-MT (option) §1; Table 1.1
MT (region) §A; Table A.1
mt (ISO code)
see maltese
Mtei (script) §A; Table A.2
MU (region) §A; Table A.1
Mult (script) §A; Table A.2
MV (region) §A; Table A.1
MW (region) §A; Table A.1
MX (region) §A; Table A.1
MY (region) §A; Table A.1
my (ISO code)
see burmese
Mymr (script) §A; Table A.2
MZ (region) §A; Table A.1
[top]

## N[link]

NA (region) §A; Table A.1
na (ISO code)
see nauruan
Narb (script) §A; Table A.2
nauruan (root language) §1; Table 1.2
naustrian (option) §1; Table 1.3; 51
navajo (root language) §1; Table 1.2
nb (ISO code)
see bokmal
Nbat (script) §A; Table A.2
nbelgiangerman (option) §1; Table 1.3
NC (region) §A; Table A.1
nd (ISO code)
see northernndebele
ndonga (root language) §1; Table 1.2
NE (region) §A; Table A.1
ne (ISO code)
see nepali
nepali (root language) §1; Table 1.2
netherlands (option) §1; Table 1.3
Newa (script) §A; Table A.2
newzealand (option) §1; Table 1.3
NF (region) §A; Table A.1
NG (region) §A; Table A.1
ng (ISO code)
see ndonga
ngerman (option) §1; Table 1.3; 35, 71, 78
ngerman package 35, 56
ngermanb (option) §1; Table 1.3
ngermanDE (option) §1; Table 1.3; 71, 78
NI (region) §A; Table A.1
nicaraguanspanish (option) §1; Table 1.3
nil (option) §1; Table 1.3
Nkgb (script) §A; Table A.2
nko (root language) §1; Table 1.2
Nkoo (script) §A; Table A.2
nl-BE (option) §1; Table 1.1
nl-NL (option) §1; Table 1.1
NL (region) §A; Table A.1
nl (ISO code)
see dutch
nn (ISO code)
see nynorsk
NO (region) §A; Table A.1
no (ISO code)
see norsk
norsk (root language) §1; Table 1.2
northernndebele (root language) §1; Table 1.2
northernsotho (root language) §1; Table 1.2
norwegian (option) §1; Table 1.3
noverbose §3; 19, 115
nowarn §3; 19
NP (region) §A; Table A.1
nqo (ISO code)
see nko
NR (region) §A; Table A.1
nr (ISO code)
see southernndebele
Nshu (script) §A; Table A.2
nso (ISO code)
see northernsotho
nswissgerman (option) §1; Table 1.3
NU (region) §A; Table A.1
nuosu (root language) §1; Table 1.2
nv (ISO code)
see navajo
ny (ISO code)
see chichewa
nynorsk (root language) §1; Table 1.2
NZ (region) §A; Table A.1
[top]

## O[link]

oc (ISO code)
see occitan
occitan (root language) §1; Table 1.2
Ogam (script) §A; Table A.2
oj (ISO code)
see ojibwe
ojibwe (root language) §1; Table 1.2
Olck (script) §A; Table A.2
OM (region) §A; Table A.1
om (ISO code)
see oromo
or (ISO code)
see oriya
oriya (root language) §1; Table 1.2
Orkh (script) §A; Table A.2
oromo (root language) §1; Table 1.2
Orya (script) §A; Table A.2
os (ISO code)
see ossetian
Osge (script) §A; Table A.2
Osma (script) §A; Table A.2
ossetian (root language) §1; Table 1.2
[top]

## P[link]

PA (region) §A; Table A.1
pa (ISO code)
see easternpunjabi
pali (root language) §1; Table 1.2
Palm (script) §A; Table A.2
panamaspanish (option) §1; Table 1.3
paraguayspanish (option) §1; Table 1.3
pashto (root language) §1; Table 1.2
Pauc (script) §A; Table A.2
pdflatex (application) 24
PE (region) §A; Table A.1
Perm (script) §A; Table A.2
persian (option) §1; Table 1.3
peruvianspanish (option) §1; Table 1.3
PF (region) §A; Table A.1
PG (region) §A; Table A.1
PH (region) §A; Table A.1
Phag (script) §A; Table A.2
Phli (script) §A; Table A.2
Phlp (script) §A; Table A.2
Phlv (script) §A; Table A.2
Phnx (script) §A; Table A.2
pi (ISO code)
see pali
piedmontese (root language) §1; Table 1.2
piemonteis (option) §1; Table 1.3
Piqd (script) §A; Table A.2
PK (region) §A; Table A.1
PL (region) §A; Table A.1
pl (ISO code)
see polish
Plrd (script) §A; Table A.2
PM (region) §A; Table A.1
pms (ISO code)
see piedmontese
PN (region) §A; Table A.1
polish (root language) §1; Table 1.2
polutoniko (option) §1; Table 1.3
polutonikogreek (option) §1; Table 1.3
polyglossia package a, 2, 9, 11–13, 35, 44, 55, 59, 62, 95
portugal (option) §1; Table 1.3
portuges (root language) §1; Table 1.2
portuguese (option) §1; Table 1.3
POSIX (Portable Operating System Interface) 23, 41, 79
PR (region) §A; Table A.1
〈prefix〉-〈localeid〉.ldf 15, 16, 51–56, 58–67, 69, 81
`\ProvidesFile` 53, 110
Prti (script) §A; Table A.2
PS (region) §A; Table A.1
ps (ISO code)
see pashto
pt-BR (option) §1; Table 1.1
pt-PT (option) §1; Table 1.1
PT (region) §A; Table A.1
pt (ISO code)
see portuges
puertoricospanish (option) §1; Table 1.3
PW (region) §A; Table A.1
PY (region) §A; Table A.1
[top]

## Q[link]

QA (region) §A; Table A.1
Qaaa (script) §A; Table A.2
Qaai (script) §A; Table A.2
Qabx (script) §A; Table A.2
qu (ISO code)
see quechua
quechua (root language) §1; Table 1.2
[top]

## R[link]

RE (region) §A; Table A.1
region
see territory
regions.sty 62, 63
`\RequirePackage` 13, 17, 72
Rjng (script) §A; Table A.2
rm-CH (option) §1; Table 1.1
rm (ISO code)
see romansh
rn (ISO code)
see kirundi
RO (region) §A; Table A.1
ro (ISO code)
see romanian
romanche (option) §1; Table 1.3
romanian (root language) §1; Table 1.2
romansch (option) §1; Table 1.3
romansh (root language) §1; Table 1.2
Roro (script) §A; Table A.2
RS (region) §A; Table A.1
RU (region) §A; Table A.1
ru (ISO code)
see russian
rumantsch (option) §1; Table 1.3
Runr (script) §A; Table A.2
russian (root language) §1; Table 1.2
russianb (option) §1; Table 1.3
RW (region) §A; Table A.1
rw (ISO code)
see kinyarwanda
[top]

## S[link]

SA (region) §A; Table A.1
sa (ISO code)
see sanskrit
samin (root language) §1; Table 1.2
samoan (root language) §1; Table 1.2
Samr (script) §A; Table A.2
sango (root language) §1; Table 1.2
sanmarino (option) §1; Table 1.3
sanskrit (root language) §1; Table 1.2
Sara (script) §A; Table A.2
Sarb (script) §A; Table A.2
sardinian (root language) §1; Table 1.2
Saur (script) §A; Table A.2
SB (region) §A; Table A.1
SC (region) §A; Table A.1
sc (ISO code)
see sardinian
sco (ISO code)
see scots
scots (root language) §1; Table 1.2
scottish (root language) §1; Table 1.2
script 10, 11, 13, 15, 16, 21, 36, 43, 44, 48, 51, 52, 62
SD (region) §A; Table A.1
sd (ISO code)
see sindhi
SE (region) §A; Table A.1
se (ISO code)
see samin
`\selectlanguage` 2, 18, 73
serbian (root language) §1; Table 1.2; 79
serbianc (option) §1; Table 1.3
serbianl (option) §1; Table 1.3
`\SetCurrentTrackedDialect` §6.2; 10, 18, 46, 73, 74, 75, 96, 97, 101, 102
`\SetTrackedDialectAdditional` §6.6; 80, 102
`\SetTrackedDialectLabelMap` §6.6; 13, 18, 74, 78, 81, 102
`\SetTrackedDialectModifier` §6.6; 34, 78, 79, 102
`\SetTrackedDialectScript` §6.6; 79, 103
`\SetTrackedDialectSubLang` §6.6; 80, 103
`\SetTrackedDialectVariant` §6.6; 79, 103
SG (region) §A; Table A.1
sg (ISO code)
see sango
Sgnw (script) §A; Table A.2
SH (region) §A; Table A.1
Shaw (script) §A; Table A.2
shell escape a, 10, 22, 23, 25, 27, 94, 110, 111
shellesc package 94
shona (root language) §1; Table 1.2
Shrd (script) §A; Table A.2
SI (region) §A; Table A.1
si (ISO code)
see sinhalese
Sidd (script) §A; Table A.2
Sind (script) §A; Table A.2
sindhi (root language) §1; Table 1.2
Sinh (script) §A; Table A.2
sinhalese (root language) §1; Table 1.2
SJ (region) §A; Table A.1
SK (region) §A; Table A.1
sk (ISO code)
see slovak
sl-SI (option) §1; Table 1.1
SL (region) §A; Table A.1
sl (ISO code)
see slovene
slovak (root language) §1; Table 1.2
slovene (root language) §1; Table 1.2
sloveneistriaitalian (option) §1; Table 1.3
sloveneistriaslovenian (option) §1; Table 1.3
slovenia (option) §1; Table 1.3
slovenian (option) §1; Table 1.3
SM (region) §A; Table A.1
sm (ISO code)
see samoan
SN (region) §A; Table A.1
sn (ISO code)
see shona
SO (region) §A; Table A.1
so (ISO code)
see somali
somali (root language) §1; Table 1.2
Sora (script) §A; Table A.2
southernndebele (root language) §1; Table 1.2
southernsotho (root language) §1; Table 1.2
spainspanish (option) §1; Table 1.3
spanish (root language) §1; Table 1.2; 3
sq (ISO code)
see albanian
SR (region) §A; Table A.1
sr (ISO code)
see serbian
SS (region) §A; Table A.1
ss (ISO code)
see swati
ST (region) §A; Table A.1
st (ISO code)
see southernsotho
su (ISO code)
see sudanese
sudanese (root language) §1; Table 1.2
Sund (script) §A; Table A.2
SV (region) §A; Table A.1
sv (ISO code)
see swedish
sw (ISO code)
see swahili
swahili (root language) §1; Table 1.2
swati (root language) §1; Table 1.2
swedish (root language) §1; Table 1.2
swissfrench (option) §1; Table 1.3
swissgerman (option) §1; Table 1.3
swissitalian (option) §1; Table 1.3
swissromansh (option) §1; Table 1.3
SX (region) §A; Table A.1
SY (region) §A; Table A.1
Sylo (script) §A; Table A.2
syr (ISO code)
see syriac
Syrc (script) §A; Table A.2
Syre (script) §A; Table A.2
syriac (root language) §1; Table 1.2
Syrj (script) §A; Table A.2
Syrn (script) §A; Table A.2
SZ (region) §A; Table A.1
[top]

## T[link]

ta (ISO code)
see tamil
tagalog (root language) §1; Table 1.2
Tagb (script) §A; Table A.2
tahitian (root language) §1; Table 1.2
tai (root language) §1; Table 1.2
tajik (root language) §1; Table 1.2
Takr (script) §A; Table A.2
Tale (script) §A; Table A.2
Talu (script) §A; Table A.2
tamil (root language) §1; Table 1.2
Taml (script) §A; Table A.2
Tang (script) §A; Table A.2
tatar (root language) §1; Table 1.2
Tavt (script) §A; Table A.2
TC (region) §A; Table A.1
TD (region) §A; Table A.1
te (ISO code)
see telugu
Telu (script) §A; Table A.2
telugu (root language) §1; Table 1.2
Teng (script) §A; Table A.2
territory 20, 26, 30, 31, 35, 36, 51, 62, 63, 106, 108, 109, 111
tex (application) 26
texosquery.cfg a
texosquery.tex 9, 10
texosquery (application) a, 10
texosquery package 10, 22, 23, 26
`\TeXOSQueryLangTag` 10, 14, 22
`\TeXOSQueryLocale` 23, 26
TF (region) §A; Table A.1
Tfng (script) §A; Table A.2
TG (region) §A; Table A.1
tg (ISO code)
see tajik
Tglg (script) §A; Table A.2
TH (region) §A; Table A.1
th (ISO code)
see thai
Thaa (script) §A; Table A.2
Thai (script) §A; Table A.2
thai (root language) §1; Table 1.2
`\ThreeLetterExtIsoLanguageCode` §5; 40, 103
`\ThreeLetterIsoLanguageCode` §5; 40, 103
ti (ISO code)
see tigrinya
tibetan (root language) §1; Table 1.2
Tibt (script) §A; Table A.2
tigrinya (root language) §1; Table 1.2
Tirh (script) §A; Table A.2
TJ (region) §A; Table A.1
TK (region) §A; Table A.1
tk (ISO code)
see turkmen
TL (region) §A; Table A.1
tl (ISO code)
see tagalog
TM (region) §A; Table A.1
TN (region) §A; Table A.1
tn (ISO code)
see tswana
TO (region) §A; Table A.1
to (ISO code)
see tonga
tonga (root language) §1; Table 1.2
TR (region) §A; Table A.1
tr (ISO code)
see turkish
`\TrackedDialectClosestSubMatch` §5; 36, 103
`\TrackedDialectsFromLanguage` §5; 39, 103
`\TrackedIsoCodeFromLanguage` §5; 40, 104
`\TrackedLanguageFromDialect` §5; 39, 104
`\TrackedLanguageFromIsoCode` §5; 39, 40, 104
`\TrackIfKnownLanguage` §3; 14, 21, 104
tracklang.sty
see tracklang
tracklang.tex a, 9, 10, 13, 19, 30, 73, 95–112, 114
tracklang-region-codes.tex §4; 30, 31, 73, 75, 104, 105, 107–111
tracklang-scripts.sty
see tracklang-scripts
tracklang-scripts.tex §4; 11, 31, 32, 33, 43, 73, 75, 104, 112–114
tracklang-scripts package 11, 31, 43, 74
tracklang package a, 9, 19, 30, 35, 72, 95
`\TrackLangAddExtraRegionFile` §4; 31, 73, 76, 104
`\TrackLangAddExtraScriptFile` §4; 33, 73, 75, 104
`\TrackLangAddToCaptions` §5; 15, 16, 56, 71, 78, 104
`\TrackLangAddToHook` §5; 16, 18, 55, 71, 104, 105, 111
`\TrackLangAlphaIIIToNumericRegion` §4; 30, 105
`\TrackLangAlphaIIToNumericRegion` §4; 30, 105
`\TrackLangDeclareDialectOption` 105
`\TrackLangDeclareLanguageOption` 105
`\TrackLangEncodingName` §5; 54, 105
`\TrackLangEnv` §3; 25, 26, 27, 105, 106, 110, 114
`\TrackLangEnvCodeSet` §3; 26, 106
`\TrackLangEnvLang` §3; 26, 106
`\TrackLangEnvModifier` §3; 26, 106
`\TrackLangEnvTerritory` §3; 26, 106
`\TrackLangFromEnv` §3; 9, 10, 15, 23, 25–28, 34, 41, 81, 82, 106
`\TrackLangGetDefaultScript` §5; 43, 106
`\TrackLangGetKnownCountry` 106
`\TrackLangGetKnownIsoThreeLetterLang` 106
`\TrackLangGetKnownIsoThreeLetterLangB` 107
`\TrackLangGetKnownIsoTwoLetterLang` 107
`\TrackLangGetKnownLangFromIso` 107
`\TrackLangIfAlphaNumericChar` 107
`\TrackLangIfHasDefaultScript` 107
`\TrackLangIfHasKnownCountry` 107
`\TrackLangIfKnownAlphaIIIRegion` §4; 31, 107
`\TrackLangIfKnownAlphaIIRegion` §4; 30, 108
`\TrackLangIfKnownIsoThreeLetterLang` 108
`\TrackLangIfKnownIsoThreeLetterLangB` 108
`\TrackLangIfKnownIsoTwoLetterLang` 108
`\TrackLangIfKnownLang` 82, 108
`\TrackLangIfKnownLangFromIso` 108
`\TrackLangIfKnownNumericRegion` §4; 30, 109
`\TrackLangIfLanguageTag` 109
`\TrackLangIfRegionTag` 109
`\TrackLangIfScriptTag` 109
`\TrackLangIfVariantTag` 109
`\TrackLangLastTrackedDialect` §6.5; 13, 77, 78, 95, 109
`\TrackLangNewLanguage` §6.5; 73, 76, 77, 82, 96, 109
`\TrackLangNumericToAlphaIIIRegion` §4; 31, 110
`\TrackLangNumericToAlphaIIRegion` §4; 30, 110
`\TrackLangParseFromEnv` §3; 27, 105, 106, 110
`\TrackLangProvidePredefinedDialect` §6.6; 73, 77, 110
`\TrackLangProvidePredefinedLanguage` §6.6; 73, 77, 110
`\TrackLangProvidesResource` §5; 15, 16, 46, 53, 54, 81, 110
`\TrackLangQueryEnv` §3; 26, 110
`\TrackLangQueryOtherEnv` §3; 27, 111
`\TrackLangRedefHook` §5; 16, 18, 56, 111
`\TrackLangRegionMap` §4; 31, 73, 76, 111
`\TrackLangRequestResource` §5; 16, 54, 111
`\TrackLangRequireDialect` §5; 15, 46, 53, 55, 56, 63, 111, 112
`\TrackLangRequireDialectOmitDialectLabel` §5; 46, 111
`\TrackLangRequireDialectOmitDialectLabelOmitOnlyRegion` §5; 46, 111
`\TrackLangRequireDialectOmitOnlyRegion` §5; 46, 112
`\TrackLangRequireDialectPrefix` §5; 46, 112
`\TrackLangRequireResource` §5; 46, 50, 54, 81, 111, 112
`\TrackLangRequireResourceOrDo` §5; 54, 112
`\TrackLangScriptAlphaToDir` §4; 11, 32, 112
`\TrackLangScriptAlphaToName` §4; 11, 32, 112
`\TrackLangScriptAlphaToNumeric` §4; 11, 32, 112
`\TrackLangScript〈Code〉` §4; 11, 32, 43, 113
`\TrackLangScriptGetParent` §4; 33, 113
`\TrackLangScriptIfHasParent` §4; 33, 113
`\TrackLangScriptIfKnownAlpha` §4; 32, 113
`\TrackLangScriptIfKnownNumeric` §4; 32, 113
`\TrackLangScriptMap` §4; 32, 33, 73, 75, 113
`\TrackLangScriptNumericToAlpha` §4; 32, 113
`\TrackLangScriptSetParent` §4; 33, 114
`\TrackLangShowWarningsfalse` §3; 24, 114
`\TrackLangShowWarningstrue` §3; 24, 114
`\TrackLanguageTag` §3; Table 1.1; 10, 13–15, 17, 21, 23, 30, 34, 36, 39, 40, 42, 74, 78, 104, 114
`\TrackLocale` §3; Table 1.1; 20, 22, 23, 26, 34, 36, 41, 74, 78, 79, 114
`\TrackPredefinedDialect` §3; Table 1.1; 3, 10, 17, 19, 20, 73, 74, 77, 78, 105, 110, 114
`\trans@languages` 35
translator package 2, 35
ts (ISO code)
see tsonga
tsonga (root language) §1; Table 1.2
tswana (root language) §1; Table 1.2
TT (region) §A; Table A.1
tt (ISO code)
see tatar
turkish (root language) §1; Table 1.2
turkmen (root language) §1; Table 1.2
TV (region) §A; Table A.1
TW (region) §A; Table A.1
tw (ISO code)
see twi
twi (root language) §1; Table 1.2
`\TwoLetterIsoCountryCode` §5; 40, 114
`\TwoLetterIsoLanguageCode` §5; 40, 114
ty (ISO code)
see tahitian
TZ (region) §A; Table A.1
[top]

## U[link]

UA (region) §A; Table A.1
UG (region) §A; Table A.1
ug (ISO code)
see uyghur
Ugar (script) §A; Table A.2
uk (ISO code)
see ukrainian
UKenglish (option) §1; Table 1.3; 13, 17, 18, 34, 55, 71
ukraine (option) §1; Table 1.3
ukraineb (option) §1; Table 1.3
ukrainian (root language) §1; Table 1.2
UM (region) §A; Table A.1
und (ISO code)
see undetermined
undetermined (root language) §1; Table 1.2; 40, 97
uppersorbian (option) §1; Table 1.3
ur (ISO code)
see urdu
urdu (root language) §1; Table 1.2
uruguayspanish (option) §1; Table 1.3
US (region) §A; Table A.1
USenglish (option) §1; Table 1.3; 71
usorbian (root language) §1; Table 1.2
UY (region) §A; Table A.1
uyghur (root language) §1; Table 1.2
UZ (region) §A; Table A.1
uz (ISO code)
see uzbek
uzbek (root language) §1; Table 1.2
[top]

## V[link]

VA (region) §A; Table A.1
Vaii (script) §A; Table A.2
valencian (option) §1; Table 1.3
valencien (option) §1; Table 1.3
variant 10, 15, 20, 36, 48, 51, 77, 79
vatican (option) §1; Table 1.3
VC (region) §A; Table A.1
VE (region) §A; Table A.1
ve (ISO code)
see venda
venda (root language) §1; Table 1.2
venezuelanspanish (option) §1; Table 1.3
verbose §3; 19, 115
VG (region) §A; Table A.1
VI (region) §A; Table A.1
vi (ISO code)
see vietnamese
vietnamese (root language) §1; Table 1.2
Visp (script) §A; Table A.2
VN (region) §A; Table A.1
vo (ISO code)
see volapuk
volapuk (root language) §1; Table 1.2
VU (region) §A; Table A.1
[top]

## W[link]

wa (ISO code)
see walloon
walloon (root language) §1; Table 1.2
Wara (script) §A; Table A.2
warn §3; 19
welsh (root language) §1; Table 1.2
westernfrisian (root language) §1; Table 1.2
WF (region) §A; Table A.1
wo (ISO code)
see wolof
Wole (script) §A; Table A.2
wolof (root language) §1; Table 1.2
WS (region) §A; Table A.1
[top]

## X[link]

xh (ISO code)
see xhosa
xhosa (root language) §1; Table 1.2
Xpeo (script) §A; Table A.2
`\xpg@bcp@loaded` 2, 11, 35
`\xpg@loaded` 35
Xsux (script) §A; Table A.2
[top]

## Y[link]

YE (region) §A; Table A.1
yi (ISO code)
see yiddish
yiddish (root language) §1; Table 1.2
Yiii (script) §A; Table A.2
yo (ISO code)
see yoruba
yoruba (root language) §1; Table 1.2
YT (region) §A; Table A.1
[top]

## Z[link]

ZA (region) §A; Table A.1
za (ISO code)
see zhuang
zh (ISO code)
see chinese
zhuang (root language) §1; Table 1.2
Zinh (script) §A; Table A.2
ZM (region) §A; Table A.1
Zmth (script) §A; Table A.2
Zsye (script) §A; Table A.2
Zsym (script) §A; Table A.2
zu (ISO code)
see zulu
zulu (root language) §1; Table 1.2
ZW (region) §A; Table A.1
Zxxx (script) §A; Table A.2
Zyyy (script) §A; Table A.2
Zzzz (script) §A; Table A.2

1Thass Broad Norfolk, my bewties `:-P`