Skip to content

findLocale

Converts a 2-letter language code into a full language-region locale string (e.g., “en” to “en-US”).

Expands a two-letter language code to the full language-region tag the dictionaries are keyed by, preferring a well-known default (en → en-US, pt → pt-BR) and otherwise the region that matches the language (de → de-DE). A full five-character tag or an unknown code is returned unchanged.

import {findLocale} from "@d3plus/locales";

findLocale("en");
findLocale("pt");
findLocale("es");
findLocale("de");
findLocale("fr");
findLocale("zh");
findLocale("xx");
findLocale("en-GB");

Parameters

import {findLocale} from "@d3plus/locales";
localerequiredstring

A 2-letter language code (e.g., "en", "fr").