Reference · Where every tie sits
countryNamefunction
The name of a country in a language, from its ISO 3166 code, through Intl.DisplayNames: no list to write ("DE" is
Germany, Allemagne, ドイツ, Alemania, Deutschland). The home nations (GB-ENG, GB-SCT, GB-WLS, GB-NIR) are not regions
to Intl, so they have names here. A code Intl does not know gives undefined.
Import it
import { countryName } from "@johnmorrisdotca/taisen-brackets/layout";
Also exported from: @johnmorrisdotca/taisen-brackets
Definition
function countryName(code: string, locale?: string | Locale): string | undefined
Parameters
| Name | Type | Description |
|---|---|---|
code | string | The country's ISO 3166 code: |
locale (optional) | string | Locale | The language, as for |
Returns
string | undefined
The name, or undefined when the code is not a country the runtime knows.
Examples
import { countryName } from "@johnmorrisdotca/taisen-brackets";
console.log(countryName("JP", "en"), countryName("JP", "ja"));Japan 日本What it prints (run when this page was built)