Reference · Framing, geometry and quiz tools
nameOffunction
What a region is called in a language: the English name, or in Japanese the everyday short name where there is one (アメリカ), else the full Japanese name, else the English.
Import it
import { nameOf } from "@johnmorrisdotca/chizu";
Definition
function nameOf(region: Pick<ChizuRegion, "name" | "nameJa" | "nameShortJa">, language: ChizuLanguage): string
Parameters
| Name | Type | Description |
|---|---|---|
region | Pick<ChizuRegion, "name" | "nameJa" | "nameShortJa"> | The native region, or built-in map selector where the signature requires text. |
language | ChizuLanguage | The English or Japanese display language. |
Returns
string
What a region is called in a language: the English name, or in Japanese the everyday short name where there is one (アメリカ), else the full Japanese name, else the English.
Examples
import WORLD from "@johnmorrisdotca/chizu/world";
import { nameOf } from "@johnmorrisdotca/chizu";
const us = WORLD.regions.find((region) => region.code === "US")!;
console.log(nameOf(us, "en"), nameOf(us, "ja"));
// United States アメリカUnited States アメリカWhat it prints (run when this page was built)