Reference · Country and region names
flagNamefunction
The name of a flag's place, in English or Japanese, as Kuni gives it: what a screen reader should say for the
flag, or a caption. Any language tag that starts with ja is Japanese; anything else is English.
Import it
import { flagName } from "@johnmorrisdotca/hata/names";
Definition
function flagName(code: string, lang?: string): string | null
Parameters
| Name | Type | Description |
|---|---|---|
code | string | A flag's code, in any case: "JP", "jp-13", "CA-ON". |
lang (optional) | string |
|
Returns
string | null
The name, or null when the code has no flag here.
Examples
import { flagName } from "@johnmorrisdotca/hata/names";
console.log(flagName("JP-13")); // "Tokyo"
console.log(flagName("jp-13", "ja")); // "東京都"
console.log(flagName("DE-BY", "ja-JP")); // "バイエルン自由州"
console.log(flagName("XX")); // nullTokyo
東京都
バイエルン自由州
nullWhat it prints (run when this page was built)