Namestype
One language's names: what an entry @johnmorrisdotca/kuni/names/<language> exports. Every function is pure.
Import it
import type { Names } from "@johnmorrisdotca/kuni/names/fr";
Also exported from: @johnmorrisdotca/kuni/names/es, @johnmorrisdotca/kuni/names/de, @johnmorrisdotca/kuni/names/zh-Hans, @johnmorrisdotca/kuni/names/zh-Hant, @johnmorrisdotca/kuni/names/ko, @johnmorrisdotca/kuni/names/pt, @johnmorrisdotca/kuni/names/ar, @johnmorrisdotca/kuni/names/ru
Definition
interface Names {
readonly language: NamesLanguage;
countryName(code: string, options?: NamesNameOptions): string | null;
countryVariants(code: string): readonly string[];
countryByName(text: string): CountryCode | null;
countries(options?: NamesListOptions): readonly NamedCountry[];
fold(text: string): string;
}
Members
| Name | Type | Description |
|---|---|---|
language | NamesLanguage | The language of this entry. |
countryName | (code: string, options?: NamesNameOptions): string | null | A country's name in this language, as |
countryVariants | (code: string): readonly string[] | The variant forms CLDR gives for a country in this language; empty for most and for a code that is not a country. |
countryByName | (text: string): CountryCode | null | The country somebody typed, by name, short form, variant or alias in this language (or its alpha-2 code), as |
countries | (options?: NamesListOptions): readonly NamedCountry[] | All 250 countries with their names in this language, in the order asked. |
fold | (text: string): string | What two ways of typing a name have in common in this language, as |
Examples
import type { Names } from "@johnmorrisdotca/kuni/names/fr";
const read = (names: Names): string | null => names.countryName("JP");
console.log(typeof read); // "function"functionWhat it prints (run when this page was built)