Locale data by country and currency, the same on every platform. For the web, Swift, Android and AI agents, with zero dependencies on each:
- Countries: every ISO 3166-1 code (249), Kosovo (
XK) and the codes ISO reserves for places and bodies that are not countries (EU,UN,AC,CP,DG,EA,IC,TA): alpha-2, alpha-3 and numeric codes, status, emoji flag, official languages, currencies, calling codes, internet domain, continent, IANA time zones and native names. - Currencies: ISO 4217's in use, the market's own (
CNH,GGP,FOK…), the units of account (UI,UP,UR…) and the withdrawn codes the market still quotes: numeric code, minor units, three symbols (USD,US$,$), the countries that use each and the region whose flag stands for it. - Names of every country and currency in ten languages: English, Spanish, Brazilian Portuguese, French, Italian, German, Russian, Arabic, and Chinese (simplified and traditional), each its own file, so an app carries the ones it shows; and of every collection, in English and Spanish.
- Collections of countries, so an app can serve some and leave others out: regions (
southern-cone,latin-america…), blocs and currency areas (mercosur,eu,eurozone…) and each authority's sanctions, by the threshold each one's definition states. - Flags for every code: square, cropped so a circle can clip them (SVG, an asset catalog, vector drawables).
import { country, currency, supported } from "locale-atlas";
import es from "locale-atlas/names/es";
country("UY"); // { code: "UY", alpha3: "URY", emoji: "🇺🇾", callingCodes: ["+598"], timezones: ["America/Montevideo"], … }
currency("UYU")?.symbols; // { code: "UYU", international: "$U", local: "$" }
es.country("BR"); // "Brasil"
supported({ include: ["latin-america"], exclude: ["sanctions-us-comprehensive"] });
<img src="https://cdn.jsdelivr.net/npm/[email protected]/flags/UY.svg" alt="" width="32" height="32" style="border-radius: 50%">
No keys and no accounts. Only facts go in, each checked against the sources cited for it, and the flags' public domain (or copyright-exempt) drawings; no text or table is copied (Credits). The package is MIT.
| Platform | Install | The data, as | The flags, as |
|---|---|---|---|
| The web, Node 22.13+, Deno, Bun, Workers | npm locale-atlas (ESM), or jsDelivr with no install |
ES modules, one per part and per language | SVG files: locale-atlas/flags/UY.svg |
| iOS 15+, macOS 12+, tvOS 15+, watchOS 8+, visionOS | Swift Package Manager, from this repository | JSON in the module's bundle, decoded on first use | An asset catalog: flag-uy |
| Android 7.0+ (API 24) | JitPack, from this repository | JSON in the library, read with the platform's org.json on first use |
Vector drawables: io.localeatlas.R.drawable.locale_atlas_flag_uy |
| AI agents | npx locale-atlas skill |
Whichever the project uses: the skill knows each |
Why one atlas
An app on the web, on iOS and on Android asks each the same questions: a country's name in the user's language and its flag, the currencies used there and how each is written, the market's codes ISO lacks (CNH, GGP), the countries a bloc or a sanctions programme covers. Answered apart on each platform, the answers disagree: a country named one way in a browser and another on a phone, a name that changes when a system updates rather than when the app does.
This package is one list for all of them. What it does, and why:
- One source, every platform. A fact is kept in one place,
data/; every platform's copy is made from it, and a file of answers (test/golden.json) is asked of the web, Swift and Kotlin alike, so a platform that answers otherwise fails its own tests. A version names a country the same way everywhere, and the name changes only when the app takes a new version. - Facts, checked at their sources. Every fact is checked against the sources cited for it, and only facts are taken from them, with no text or table copied; the flags are public domain (or copyright-exempt) drawings, cropped and flattened, or drawn from their law (Credits). Where no source settles a fact, the package's own choice says so where it is kept (an international symbol, a Spanish name, a collection's threshold).
- A code in, an answer or null out. Any of a country's ISO codes, in any case, finds it, and anything else gives null, never an error, so a list of codes maps straight to records, names and flags. The one exception is a collection id that doesn't exist:
supportedthrows for it, so a typo never serves a sanctioned country. - Each language its own file. An app carries the languages it shows, the user's is picked the same way on every platform, and a name a language lacks is English's, so a known code always has one.
- Flags as squares, cut for a circle. Each square is cut from its flag where the mark is (Uruguay's sun, the stars of the United States), so the circle an app clips it to shows what makes that flag that flag.
Quick start
On the web
npm install locale-atlas
Plain ESM: Node 22.13+, Deno (npm:locale-atlas), Bun, Workers and any bundler. With no install, jsDelivr serves the package as npm has it: each flag at https://cdn.jsdelivr.net/npm/[email protected]/flags/UY.svg, the flag functions at …/[email protected]/dist/flags.js (about 4 kB gzipped, no table), Spanish names at …/[email protected]/dist/names/es.js (about 7 kB), and the whole module at …/[email protected]/dist/index.js, which brings every table, the collections' with their notes and sources (about 76 kB gzipped, as jsDelivr serves the files, unminified): a page that shows only flags, or only names, imports their module rather than this one. Pin the version, as these do: a new release may redraw a flag or rename a country, and a floating URL would change it under a published page.
import { collection, collections, COLLECTIONS_AS_OF, countries, country, currencies, currency, supported, TZDB_VERSION } from "locale-atlas";
const uy = country("UY"); // country("uy"), country("URY") and country("858") are the same object
uy?.emoji; // "🇺🇾"
uy?.currencies; // ["UYU"]
uy?.callingCodes; // ["+598"]
uy?.timezones; // ["America/Montevideo"], from the tzdb release TZDB_VERSION ("2026f")
uy?.nativeNames; // [{ lang: "es", name: "Uruguay" }]
countries(); // every country, sorted by code
currency("UYU")?.symbols; // { code: "UYU", international: "$U", local: "$" }
currency("UYU")?.flagRegion; // "UY": the region whose flag stands for it
currency("JPY")?.minorUnits; // 0
currency("UI"); // { iso: false, isoEquivalent: "UYI", kind: "unit-of-account", … }
currencies(); // every currency, sorted by code
collection("mercosur")?.members; // its members' codes, sorted
collection("mercosur")?.countries; // the same, as country() gives them
collections(); // every collection, with its definition, sources and asOf (COLLECTIONS_AS_OF: the latest)
supported({ include: ["latin-america"], exclude: ["sanctions-us-comprehensive"] }); // Country[], sorted
supported({ include: [] }); // []: an empty include serves none; leave include out to start from every country
Names come one language at a time. When the page knows its language, import it; when the user's languages decide, names picks the best the package has and loads only that one:
import es from "locale-atlas/names/es";
es.country("DE"); // "Alemania"
es.country("DEU"); // null: names take the alpha-2; es.country(country("DEU")?.code) is "Alemania"
es.currency("UYU"); // "peso uruguayo"
es.collection("latin-america"); // "América Latina"
import { language, languages, names } from "locale-atlas";
const n = await names(navigator.languages); // ["es-UY", "en"] → Spanish; ["zh-TW"] → Traditional Chinese
n.country("UY");
language(["pt-PT"]); // "pt-BR": the closest the package has
languages; // ["ar", "de", "en", "es", "fr", "it", "pt-BR", "ru", "zh-Hans", "zh-Hant"]
The flags are files, found by code:
import { currencyFlagUrl, currencyRegion, flagPath, flagUrl, hasFlag, regions, VERSION } from "locale-atlas";
flagUrl("UY"); // "https://cdn.jsdelivr.net/npm/locale-atlas@<VERSION>/flags/UY.svg"
currencyFlagUrl("eur"); // "…/locale-atlas@<VERSION>/flags/EU.svg"
currencyFlagUrl("XAF"); // null: the CFA franc is several countries'
currencyRegion("CNH"); // "CN"
hasFlag("uy"); // true
regions; // every region with a flag
flagPath("UY"); // "flags/UY.svg", inside the package
flagUrl("UY", { cdn: "https://unpkg.com/" }); // another npm mirror; { version } pins another version
flagUrl pins the URL to the installed version (VERSION), so a page shows the flags it was built with. A round flag is the square clipped by CSS:
<img src="…/flags/UY.svg" alt="Uruguay" width="24" height="24" style="border-radius: 50%">
Everything is typed (Country, Currency, Collection, Names, unions of every CountryCode, CurrencyCode and CollectionId, so an editor completes them, and of every CurrencyKind, CollectionKind, Status and Continent, so a switch is exhaustive) and frozen.
Each part is its own module, locale-atlas/countries, /currencies, /collections, /names, /flags, each language /names/<tag>, and the package has no side effects, so a bundler keeps the modules a page uses and drops the rest. What a module brings is its whole table, not one record. Minified and gzipped, as a bundler makes them: the flag functions under 2 kB, with no table at all; country() every country's (about 15 kB, a third of it their native names); currency() every currency's (about 8 kB); a language's names about 5 kB; supported() the countries' table and each collection's members (about 17 kB in all), and none of the collections' definitions, notes and sources, which only collection() and collections() bring (about 40 kB more: the sanctions' are long, and data/collections.json ships them too); and the whole main module, with every table, about 67 kB. No language's names come with the main module. names() loads only the language it picks where the bundler splits code (Rollup, Vite, webpack, esbuild with --splitting); a single-file build (esbuild without splitting, a Worker bundled into one file) inlines all ten, so there, and wherever the language is known at build time, import it (locale-atlas/names/es). A bundler takes a flag as a file (import uy from "locale-atlas/flags/UY.svg"); a server or a build step finds it with import.meta.resolve("locale-atlas/" + flagPath("UY")). The data itself ships too, as data/*.json (its shapes): import countries from "locale-atlas/data/countries.json" with { type: "json" }.
A whole picker, the countries an app serves by name in the user's language, each with its flag: examples/web.
In Swift
In Xcode, File › Add Package Dependencies… with https://github.com/guillecura/locale-atlas; or in Package.swift:
.package(url: "https://github.com/guillecura/locale-atlas", from: "1.0.0")
// and in the target's dependencies:
.product(name: "LocaleAtlas", package: "locale-atlas")
iOS 15, macOS 12, tvOS 15, watchOS 8, visionOS 1. The module brings its data and flags in its own bundle: nothing to copy into the app.
import LocaleAtlas
let uy = LocaleAtlas.Country("UY") // or "uy", "URY", "858"; nil for a code it doesn't know
uy?.name // "Uruguay", in the user's language
uy?.name(in: "fr") // "Uruguay"
uy?.emoji // "🇺🇾"
uy?.callingCodes // ["+598"]
uy?.timeZones // [TimeZone]; uy?.timeZoneIdentifiers: ["America/Montevideo"]
LocaleAtlas.Country.all // every country, sorted by code
LocaleAtlas.tzdbVersion // "2026f": the tzdb release the time zones are from
let uyu = LocaleAtlas.Currency("UYU")
uyu?.symbols.local // "$"
uyu?.name(in: "es") // "peso uruguayo"
uyu?.kind // .national (.unitOfAccount for "UI", .localIssue for "GGP", …)
uyu?.flagRegion // "UY"; uyu?.flag: its Flag
LocaleAtlas.Names("es-UY").country("BR") // "Brasil": the best language for a tag, English if none
LocaleAtlas.Names.current // the user's (Locale.preferredLanguages, in order)
LocaleAtlas.languages // ["ar", "de", "en", …]
let names = LocaleAtlas.Names.current // once, to sort a list by name
let picker = LocaleAtlas.Country.all.sorted {
names.country($0.code)!.localizedStandardCompare(names.country($1.code)!) == .orderedAscending
}
LocaleAtlas.Collection("mercosur")?.name(in: "es") // "Mercosur"; .countries: its members as Country
LocaleAtlas.collectionsAsOf // the day the collections were last checked
do {
let served = try LocaleAtlas.supported(include: ["latin-america"], exclude: ["sanctions-us-comprehensive"])
} catch {
// LocaleAtlas.UnknownCollection: an id the package doesn't have. Fix the id; never fall back to Country.all.
}
// Flags: SwiftUI, a whole square, rounded where it is drawn. VoiceOver reads the region's name ("Uruguay").
if let flag = Flag.currency("UYU") {
flag.image.resizable().frame(width: 32, height: 32).clipShape(Circle()) // or Image(flag: flag)
}
Flag.region("eu") // the European Union's
Flag.all // every flag, by region code
LocaleAtlas.version // the package's version, as on npm
Country, Currency and Collection are Hashable, Sendable and Identifiable (by code or id), so a list can iterate Country.all. The fields are the data's, in Swift's spelling: isISO for iso, flagRegion for a currency's flag, timeZoneIdentifiers for timezones, and enums for kind, status and continent. supported throws LocaleAtlas.UnknownCollection (a LocalizedError) for an id it doesn't have; include left out starts from every country, an empty one from none. The data is JSON in the module's bundle, each file decoded with Foundation the first time something asks for it, once (the countries' table in a few milliseconds: an app that shows a list at launch can ask for Country.all off the main thread first), and each language's names only when that language is asked for; a flag reads only a small index. UIKit has flag.uiImage, AppKit flag.nsImage; the asset catalog is the module's own (flag-uy), so the flags never mix with the app's assets. If the app has a Flag of its own, write LocaleAtlas.Flag; and write LocaleAtlas.Collection always, since inside an extension LocaleAtlas a bare Collection is this type, not Swift's protocol.
The same picker in SwiftUI: examples/swiftui (swift run there, on a Mac).
On Android
// settings.gradle.kts
dependencyResolutionManagement { repositories { google(); mavenCentral(); maven("https://jitpack.io") } }
// the app's build.gradle.kts
dependencies { implementation("com.github.guillecura:locale-atlas:v1.0.0") }
An AAR of vector drawables, the data as JSON and one Kotlin object, built by JitPack from this repository's tag; nothing else comes with it. minSdk 24 (some flags draw gradients) and Kotlin 2.1 or later. The drawables are prefixed locale_atlas_, so they never meet an app's own; the data needs no Context.
import io.localeatlas.LocaleAtlas
val uy = LocaleAtlas.country("UY") // or "uy", "URY", "858"; null for a code it doesn't know
uy?.name() // "Uruguay", in the user's language
uy?.name("fr") // "Uruguay"
uy?.emoji // "🇺🇾"
uy?.callingCodes // ["+598"]
uy?.timezones // ["America/Montevideo"], from the tzdb release LocaleAtlas.tzdbVersion
uy?.flag // io.localeatlas.R.drawable.locale_atlas_flag_uy, or null
LocaleAtlas.countries // every country, sorted by code
val uyu = LocaleAtlas.currency("UYU")
uyu?.symbols?.local // "$"
uyu?.name("es") // "peso uruguayo"
uyu?.kind // Currency.Kind.NATIONAL (UNIT_OF_ACCOUNT for "UI", …)
uyu?.flagRegion // "UY"; uyu?.flag: its drawable
LocaleAtlas.names() // the user's (LocaleList.getDefault(), in order)
LocaleAtlas.names("es-UY").country("BR") // "Brasil": the best language for a tag, English if none
LocaleAtlas.names(listOf("ja", "zh-TW")) // Traditional Chinese
LocaleAtlas.languages // ["ar", "de", "en", …]
val names = LocaleAtlas.names() // once, to sort a list by name (java.text.Collator)
val picker = LocaleAtlas.countries.sortedWith(compareBy(Collator.getInstance()) { names.country(it.code)!! })
LocaleAtlas.collection("mercosur")?.name("es") // "Mercosur"; .countries: its members as Country
LocaleAtlas.collectionsAsOf // the day the collections were last checked
LocaleAtlas.supported(include = listOf("latin-america"), exclude = listOf("sanctions-us-comprehensive"))
LocaleAtlas.currencyFlag("UYU") // io.localeatlas.R.drawable.locale_atlas_flag_uy, or null
LocaleAtlas.flag("uy") // the same
LocaleAtlas.currencyRegion("EUR") // "EU"; null for "XAF", "UI", …
LocaleAtlas.VERSION // the package's version, as on npm
The fields are the data's, in Kotlin's spelling: isIso for iso, flagRegion for a currency's flag (and flag for its drawable, as a country's), and enums for kind, status and continent. supported throws IllegalArgumentException for an id it doesn't have; include left out starts from every country, an empty one from none. Write LocaleAtlas.Collection rather than importing it: imported bare, it hides Kotlin's Collection in that file. The data is JSON among the library's Java resources, read with the platform's own org.json the first time something asks for it, and each language's names only when that language is asked for; a flag reads only a small index, and nothing needs a Context. The drawables are whole 48 dp squares, neither clipped nor ringed: round them where they are drawn. In Compose:
LocaleAtlas.currencyFlag(code)?.let { flag ->
Image(painterResource(flag), contentDescription = null, Modifier.size(32.dp).clip(CircleShape))
}
In views, imageView.setImageResource(flag), clipped by the view's outline (an oval background and clipToOutline = true).
The same picker in Compose: examples/compose, an app that builds this checkout's library in place of JitPack's.
Codes and languages
Codes are ISO's, in any case. A country is found by any of its ISO 3166-1 codes (UY, URY or 858; EU for the European Union); its name and its flag by its alpha-2 (UY, EU), which country(code)?.code gives for the others. A currency is its ISO 4217 alphabetic code (UYU) or the market's where ISO has none (CNH, UI); its numeric code is a field (numeric), not a key. Every platform answers the same, and a code it does not take gives null (nil), never an error, so a list of codes maps straight to records, names and flags and leaves a gap where one has none. The one exception is a collection id that does not exist: supported throws for it, so that a typo never silently serves a sanctioned country.
Names come in the user's language unless the code asks for another: the first of the user's languages, in order, the package has (navigator.languages on the web, Locale.preferredLanguages in Swift, LocaleList.getDefault() on Android), English if none. An app that shows its own language rather than the user's passes it in: document.documentElement.lang, Bundle.main.preferredLocalizations, AppCompat's application locales.
The countries
data/countries.json: 258 codes. The 249 ISO 3166-1 assigns (status: "official"), Kosovo's XK, which ISO leaves to users and everybody uses ("user-assigned"), and the eight ISO reserves at someone's request for places and bodies that are not countries ("exceptionally-reserved"): the European Union (EU), the United Nations (UN), Ascension (AC), Clipperton (CP), Diego Garcia (DG), Ceuta and Melilla (EA), the Canary Islands (IC) and Tristan da Cunha (TA). These eight have no alpha-3 or numeric code, and supported() leaves them out unless a collection brings them in.
| Field | |
|---|---|
code, alpha3, numeric |
"UY", "URY", "858" (a string: "076" keeps its zero) |
emoji |
the code's two regional indicator symbols, "🇺🇾"; a system without that flag shows the letters |
continent |
"africa", "antarctica", "asia", "europe", "north-america", "oceania", "south-america", null for UN: the continent each is in, in the seven-continent model (Central America and the Caribbean in North America, Cyprus and Georgia in Europe, Bouvet Island, Heard Island and the French Southern Territories in Antarctica). The continent collections follow UN M49 instead, and Spanish usage for the Americas, so the two differ: continent is "north-america" for 42 codes, Panama and Jamaica among them, while collection("north-america") has 6 |
languages |
official languages, BCP 47 tags |
currencies |
the currencies in use there, each a currency() |
callingCodes |
["+598"]; the North American plan gives its places +1 and an area code ("+1787") |
tld |
".uy", or null for a place without its own |
timezones |
the IANA tz database's zones for the region, as its zone.tab lists them (the most populous first where geography allows), at the release TZDB_VERSION names (Swift: timeZoneIdentifiers, and timeZones as Foundation's); zone.tab lists neither Kosovo nor the exceptionally reserved codes, so theirs are the package's own (XK: Europe/Belgrade) |
nativeNames |
its names in its own official languages |
The currencies
data/currencies.json: every ISO 4217 code in use, and besides:
- Without an ISO code (
iso: false,numeric: null), each with the ISO code it stands for where there is one (isoEquivalent, null where there is none): the offshore renminbiCNH(→CNY); the notes territories issue at par with another's money (kind: "local-issue"): Guernsey'sGGP, Jersey'sJEP, the Isle of Man'sIMP(→GBP), the Faroes'FOK(→DKK), Kiribati'sKIDand Tuvalu'sTVD(→AUD); the units of account (kind: "unit-of-account"): Uruguay's Unidad IndexadaUI(→UYI), PrevisionalUP(→UYW) and ReajustableUR, Bolivia'sUFV, Chile'sUTMand Argentina'sUVA; and the money of two regions without an ISO code of their own (kind: "national"): Transnistria's roublePRBand the Somaliland shillingSLS. - Withdrawn (
kind: "historic"), kept because the market still quotes them:HRK,BGN,ANG,CUC,SLL,ZWL.
Each has a kind, one of eight: national, supranational (several places', or none's: EUR, XAF, XPF, XDR), fund (UYI, CLF), metal (XAU), offshore (CNH), local-issue, unit-of-account and historic; a CurrencyKind on the web, an enum in Swift and Kotlin.
A country's currencies are the ones in use there, and a currency's countries are the places where it is used or issued: every country that lists it, and, for a fund code, a unit of account, a local issue or an offshore code, the places it is issued for or chiefly traded in (UI lists Uruguay, which lists UYU; CNH lists Hong Kong; GGP and JEP each list both Guernsey and Jersey, where both pass). A withdrawn code is in use nowhere, so no country lists it and it lists none.
Each has three symbols, from the most to the least explicit: its code (USD), the international symbol that tells it apart from others written alike (US$, $U, €; the code where there is none), and the local one its own country writes ($, ¥, €), which may be another's too. Show the local one where the currency is plain from the context, the international one where several meet. The international symbol is the issuer's or its sources' where they settle one; where they settle none, or give two currencies the same, it is the package's own, the country's code before the local sign (AR$, MX$, CN¥, and BN$ and BS$, since the Brunei and the Bahamian dollar are both written B$), and the currency's notes in data/currencies.json say which. No two currencies share one, but a market code and the ISO code it stands for (UI and UYI).
Its flag, by one rule: a currency that is legal tender issued for one place with a code of its own shows that place's flag; one that several places share shows none, the euro aside, which has the European Union's. Its flagRegion (the JSON's flag) is that region; currencyRegion (Flag.currency in Swift, LocaleAtlas.currencyRegion on Android) is the same region wherever the package has its flag drawn, and null where it has none yet:
- A country's own, one code or several:
UYU→UY,USD→US;CNYand the offshoreCNH→CN,CUPandCUC→CU,SLEandSLL→SL. Other places that use it don't change it:USDis the United States' wherever it passes. - A territory's own issue has the territory's flag:
GGP→GG,JEP→JE,IMP→IM,FOK→FO,KID→KI,TVD→TV. - The euro has the European Union's:
EUR→EU.
It is null, with no flag, everywhere else: a currency several places share, whoever issues it (the CFA francs XAF and XOF, the East Caribbean dollar XCD, the CFP franc XPF of New Caledonia, French Polynesia and Wallis and Futuna, the Caribbean guilder XCG of Curaçao and Sint Maarten and the guilder ANG it replaced); the IMF's special drawing right, the metals and the other supranational units (XDR, XAU…), nobody's; the units of account and the fund codes, which are no legal tender (UI, UP, UR, UFV, UTM, UVA; UYI, UYW, CLF, COU, MXV, BOV, CHE, CHW, USN, XAD); and PRB and SLS, issued for places without a code of their own (Transnistria, in Moldova; Somaliland, in Somalia). Show those with their code. node scripts/data.ts checks the rule.
The names
data/names/: every country and currency named in English (en), Spanish (es), Brazilian Portuguese (pt-BR), French (fr), Italian (it), German (de), Russian (ru), Arabic (ar), Simplified Chinese (zh-Hans) and Traditional Chinese (zh-Hant), and every collection in English and Spanish. In English a country is named as it has asked to be, as ISO 3166 names it (Côte d'Ivoire, Cabo Verde, Czechia, Eswatini, North Macedonia, Timor-Leste, Türkiye), or as the UN does for a newer change (Naoero, Nauru until 2026), and no name starts with "The" (Bahamas, Gambia), so a list sorted by name finds each where people look. Where the sources give no Spanish name (the fund codes CHE, CHW, USN and XAD, the metals, the European units XBA to XBD, XUA), the Spanish name is the package's own translation, and the currency's notes say so. Where a language has no name of its own for a code, it has English's, so every lookup of a known code answers: es.country("UY"), es.currency("UYU"), es.collection("mercosur") on the web, Names("es") in Swift, LocaleAtlas.names("es") on Android. A country is named by its alpha-2 code.
The user's language is matched the same way on every platform (language on the web, LocaleAtlas.language(for:) in Swift, LocaleAtlas.language on Android): the first of their languages the package has, by its exact tag, then by its script (zh-TW, zh-HK and zh-MO read Traditional Chinese, any other Chinese Simplified; Mandarin, cmn, is Chinese, and Cantonese, yue, reads Traditional unless its tag says Hans or CN), then by its region, then by the language alone (es-UY → es, pt-PT → pt-BR); English when none of theirs matches. Any other language is matched by its own primary subtag only (nb, say, is not taken for no).
The collections
data/collections.json: named sets of countries, each with its kind (geographic, bloc, currency, sanctions, other), a definition, its members (and countries, the same as records), notes, sources, volatility (how often its members change) and asOf, the day its members were last checked against its sources. Its name is in each language's names (es.collection(id); name and name(in:) in Swift and Kotlin).
supported starts from the members of the collections it includes and leaves out the members of those it excludes, whichever collection brought them in. With include left out, it starts from every country but the exceptionally reserved codes; with an empty include, from none, so a list of ids built from settings that comes out empty serves nobody rather than everybody. A store that sells in Latin America but not where the US sanctions:
supported({ include: ["latin-america"], exclude: ["sanctions-us-comprehensive"] });
Each collection's definition says what it follows: an authority's own published list (a bloc's members, the Council of the EU's, OFAC's), UN M49's regions, a dictionary's usage (the Spanish names of the Americas), or a threshold of the package's own, stated in it. The sanctions collections each follow one authority's regimes, by the threshold their definition states, as of their asOf:
| Id | A country is in when | |
|---|---|---|
sanctions-us-comprehensive |
US law bars almost every dealing with it: the jurisdictions OFAC names as under comprehensive sanctions | 3 |
sanctions-us-partial |
an active OFAC country programme blocks its government or central bank, or reaches whole sectors, short of an embargo (the package's threshold: OFAC publishes none) | 6 |
sanctions-eu-broad |
an EU regime about it restricts ordinary dealings with the country as a whole (broad trade bans, its central bank, its carriers) | 4 |
sanctions-eu-targeted |
an EU regime about it has an arms embargo or lists people, short of broad sanctions | 22 |
sanctions-eu |
any EU regime about it is in force, whatever its measures | 30 |
sanctions-un |
a current UN Security Council sanctions regime is about it, whatever its measures | 14 |
sanctions-eu is the widest: sanctions-eu-broad and sanctions-eu-targeted together, and four frameworks with nobody listed under them and no embargo (Bosnia and Herzegovina, Burundi, Niger, Türkiye). It counts China for the arms embargo the European Council declared in 1989, a political declaration the EU still applies and its Sanctions Map files under China, though it is no Council legal act. So exclude: ["sanctions-eu"] stops serving China, Türkiye, Bosnia and Herzegovina, Burundi and Niger too; for the countries the EU sanctions economically, exclude sanctions-eu-broad. Each definition says what it counts and leaves out, and its notes how to narrow it.
Blocs and sanctions change. Check asOf against the news, and treat a sanctions collection as a starting point that a lawyer confirms, not as advice: sanctions programmes target people, sectors and regions as well as countries, and a collection lists only countries.
The flags
One flag for each of the 258 codes in data/countries.json, from Afghanistan's to Zimbabwe's, the European Union's and the United Nations' among them (regions lists them, hasFlag checks one). Each is a square as tall as the flag, cut from it where its mark is, so the circle inside the square shows what makes the flag that flag:
- Centred, for most (170).
- At the hoist (65), where the emblem or the canton is: Uruguay's Sun of May, the United States' stars, the Union Jack over Australia's and Niue's stars, the triangles at the hoist (Cuba's, the Czech Republic's, Mozambique's…).
- At the fly (23), where the emblem is there: Rwanda's sun, Zambia's eagle, American Samoa's eagle, the Vatican's keys, Wallis and Futuna's saltire, and the mark of every ensign that a centred square would cut at the circle's edge: the arms of Anguilla, Ascension, Bermuda, the Cayman Islands, the Falklands, Fiji, Montserrat, Pitcairn, Saint Helena, South Georgia, Tristan da Cunha, Turks and Caicos and the British Virgin Islands; New Zealand's Southern Cross, the Cook Islands' ring of stars and Tuvalu's stars (but the one in the flag's top corner, which no circle in the square holds); the palm and crown of the British Indian Ocean Territory and Diego Garcia.
- Nepal's pennant, which does not fill its square, sits on white.
They are whole squares: nothing is clipped, and only shapes wholly outside the square are dropped. A circle, a rounded square or the full square are all for the app to choose where it draws them; data/flags.json says each flag's crop.
Drawn from their law. Five flags are drawn by scripts/flags.py from their current law (Kyrgyzstan's, North Korea's, Mauritania's, South Sudan's and Syria's), and thirteen take the colours their law or standard sets (Australia's and Heard Island's, the Bahamas', Costa Rica's, Estonia's, Finland's, Iceland's, Panama's, Saudi Arabia's, South Korea's, Spain's and Ceuta and Melilla's, the United Nations'). The law's words come first; where it gives a colour as a Pantone or CIE value, or leaves a measure out, the sRGB value or the measure is a published reading of it, each cited in the script. South Georgia's motto, set as text, is left out. Left as the source drawings have them, by decision: Afghanistan's (the Islamic Republic's, the flag at the United Nations), the French Southern Territories' (France's tricolour), the British Indian Ocean Territory's and Diego Garcia's (with St Edward's Crown, where the flag now has the Tudor Crown), Honduras's (its blue is contested), the Vatican's and Belize's (its 2019 standard is not law).
Where another flag also stands for the place. The French overseas places have the source drawings' flag for each, by one rule: a local flag where those have one (French Guiana, Guadeloupe, Mayotte, Saint-Pierre and Miquelon, Wallis and Futuna), though France's tricolour is the only official flag in most of them; French Polynesia's own; New Caledonia's Kanak flag, which it flies beside the tricolour; and the tricolour for Saint-Barthélemy, Saint-Martin, Réunion and the French Southern Territories. Martinique is the one exception: the source drawings' flag for it, the snake flag of 1766, is withdrawn from official use and contested, so it has France's tricolour; the red, green and black flag the Assembly of Martinique adopted in 2023 is not drawn. Western Sahara has the flag of the Sahrawi Arab Democratic Republic, which claims it, while its record has Morocco's calling code and currency, as Morocco controls most of it. Mayotte's flag spells MAYOTTE across its top, which reaches past the circle at both ends. data/flags.json notes the ones that need it: French Guiana's, Guadeloupe's and Mayotte's local flags, New Caledonia's, the French Southern Territories', Martinique's and Western Sahara's.
How they are made. scripts/flags.py makes them from public domain drawings at a pinned commit (Credits), but for the five flags it draws from their law and the thirteen it recolours (above), and Martinique's, which is France's. It cuts each flag's square from its SVG and flattens it into plain paths in a 512 × 512 view box (uses, transforms, percentages and the viewport resolved, coordinates to a tenth), so what is left is paths, fills, strokes, clip paths and gradients, which a browser, Apple's CoreSVG and Android's vector drawables draw alike. Anything else a flag would need (text, images, masks, patterns, filters) stops the script rather than being drawn wrong. scripts/platforms.py then writes each platform's copy of the same drawing:
| Platform | Where | Size |
|---|---|---|
| The web | flags/UY.svg (npm, jsDelivr) |
512 × 512, a vector at any size; from 0.3 kB (Peru) to 227 kB (Serbia's arms), 3.3 MB in all |
| Swift | Flags.xcassets, image flag-uy (the EU's is flag-eu) |
The vector kept, declared 48 × 48 pt: what Xcode rasters, at 1x, 2x and 3x, for a system that doesn't draw the vector |
| Android | res/drawable/locale_atlas_flag_uy.xml |
A vector drawable, 48 × 48 dp, its paths in a 512 viewport |
Each platform scales the vector to the size it is drawn at, so the declared sizes only matter where nothing else is set.
With an AI agent
The package ships a skill for coding agents: when to reach for it (flags, a country picker, names in the user's language, a currency's symbol, the countries an app serves), which module for where the code runs on the web, in Swift and on Android, the calls, and the rules (names fall back to English, the data is dated, a sanctions collection follows one authority's regimes, by the threshold its definition states, and is not legal advice). Put it in the project and Claude Code reads it when the task calls for it:
npx locale-atlas skill # into .claude/skills/locale-atlas
npx locale-atlas skill --dir .agents/skills # another agent's folder
A copy there that differs (edited, or an older version's) is replaced only after a yes. npx runs it without adding the package to the project, so it works in a Swift or Android project too. With the skills CLI, from this repository: npx skills add guillecura/locale-atlas. Agents can also read this README at node_modules/locale-atlas/README.md, or at https://whitebear.io/en/oss/locale-atlas/docs.
In Claude Code it is also a plugin, from Whitebear's marketplace, which follows each release:
/plugin marketplace add guillecura/skills
/plugin install locale-atlas@whitebear
Develop
npm install
npm test # data/'s rules, every platform's copy current, test/golden.json current, the version, the skill
npm run typecheck
npm run build
python3 -I scripts/platforms.py --check # every platform's flags are what data/ makes (CI runs it too)
swift test # the Swift module, against test/golden.json (or: xcodebuild test -scheme LocaleAtlas -destination 'platform=macOS')
cd clients/android && ./gradlew assembleRelease testDebugUnitTest lint # the Android library, against test/golden.json (JDK 17 as JAVA_HOME, and the Android SDK)
data/ is the source of truth, and every platform's copy is made from it, committed, and never edited by hand. The scripts are Python's standard library and Node, run by whoever changes the data, never by whoever installs the package:
node scripts/import.ts <research>… # the researchers' files → data/: only the parts they hold change
npm run data # checks data/, writes src/data/, src/names/, the Swift and Android JSON, and test/golden.json
git clone https://github.com/google/region-flags ../region-flags
git -C ../region-flags checkout 0e84c211b1aa531d829867aab35bed35822796ff # scripts/flags.py's REGION_FLAGS_COMMIT
python3 -I scripts/flags.py ../region-flags # data/flags/<CC>.svg and data/flags.json
python3 -I scripts/platforms.py # flags/, the asset catalog, the drawables, the Kotlin flag map
scripts/import.ts keeps what the research does not decide (each currency's flag, the withdrawn currencies, the exceptionally reserved codes, any name its files leave out) and changes only the files its directories feed: a directory with only collections.json changes the collections and their names. node scripts/data.ts checks every rule data/README.md lists before it writes: every field of its type, codes well formed and sorted, every reference resolved (a country's currencies, a currency's countries and flag, a collection's members, every name and time zone a known code's), a country's currencies and a currency's countries in agreement, English naming every code. test/golden.json is what the JavaScript API answers to a sample of questions (every kind of code, in any case, and codes that are none; every language's names; language matching; every collection, and lookups by id; supported, with include left out and empty); the Swift and Kotlin tests ask their own API the same and must answer alike, and npm test fails when the file is stale. A new language is a file in data/names/; a new collection an entry in data/collections.json and its name in data/names/en.json (and in any other language that has one); each lands on every platform with npm run data. Each flag is drawn once, in scripts/flags.py, for every platform; a crop that moves (CROP) is checked by looking at the flag in a circle.
The examples run on this checkout, each as its first lines say: examples/web from any static server at the root after npm install, examples/swiftui with swift run, examples/compose with ../../clients/android/gradlew installDebug. They are not in the npm package.
A release is one number. npm version minor (or patch) bumps package.json, and its version script (scripts/version.ts) writes the new one everywhere else it is kept: src/version.ts, the Swift module's Version.swift, Android's gradle.properties, Package.swift, this README's install lines and jsDelivr URLs, and the Compose example's dependency; npm test fails when a copy disagrees. git push --follow-tags pushes the tag v<version>, and the release workflow stages it on npm with provenance (trusted publishing: no token kept anywhere), for the owner to approve on npmjs.com (or npm stage approve with 2FA), when the tag is package.json's version and npm does not have it yet; before it does, node scripts/data.ts --release refuses a fixture in data/, a collection without sources and a region without a flag. Swift Package Manager and JitPack read the tag themselves, and jsDelivr serves what npm has. The very first time, npm needs the package to exist before it trusts the workflow, and provenance needs the repository to be public: so the repository goes public, a placeholder goes up by hand (from an empty folder, a package.json with only the name, the version 0.0.0-stage and the description "Temporary package placeholder for staged publishing", a one-line README, and npm publish --access public --tag latest, as npm 11 wants a tag for a prerelease version; never the first real version, which its tag would then fail to publish again), the trusted publisher is set on npmjs.com for release.yml, stage publish only, and only then the tag (soon after: a trusted publisher no publish has used expires).
Planned, by the same rules: number and date separators.
Credits
From these sources only facts are taken, each checked against those its record cites, and from the flag drawings the drawings themselves, cropped and flattened, some recoloured to their law; no text or table is copied from any of them. Where no source settles a fact, the package's own choice says so where it is kept.
- The authorities and issuers: ISO's public code lists (ISO 3166-1, ISO 4217), the central banks and monetary authorities, and, for the collections, the lists each one's
sourcescite (a bloc's own members, the Council of the EU's, OFAC's, the UN Security Council's, the UN's M49 regions, and dictionaries for the regions' names). - Wikidata (CC0): the countries, the currencies and their names.
- Wikipedia, where a currency's notes cite it (its symbols, some of the places that use it), and its flag articles, with Flags of the World's pages, where
scripts/flags.pycites them for a colour or a measure a flag's law gives only as Pantone or CIE, or leaves out. - The IANA time zone database (public domain), release 2026f (
TZDB_VERSION). - google/region-flags' drawings at
0e84c21, Wikimedia Commons' own, each public domain or, for nine here (Armenia, Azerbaijan, Jersey, Kazakhstan, Moldova, Mexico, Malaysia, Serbia, Mayotte), exempt from copyright under its nation's law, as its COPYING says;data/flags.jsonlinks each of the nine to its Commons page. Copyright aside, some countries restrict how their flag or arms may be used (in a trademark, say).
Made by Guille Cura at Whitebear.
License
MIT