@visulima/iso-locale 1.0.0-alpha.11 → 1.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +56 -2
- package/dist/countries.d.ts +2903 -2
- package/dist/countries.js +1 -1
- package/dist/currencies.d.ts +947 -1
- package/dist/currencies.js +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/locale.d.ts +11 -1
- package/dist/locale.js +1 -1
- package/dist/packem_shared/convert6393To6391-D3AzU7ti.js +1 -0
- package/dist/regions.d.ts +1138 -4
- package/dist/regions.js +1 -1
- package/dist/timezones.d.ts +268 -2
- package/dist/timezones.js +1 -1
- package/dist/types.d.ts +5 -5
- package/package.json +1 -1
- package/dist/packem_shared/iso6393To6391-BuOs0Bzd.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## @visulima/iso-locale [1.0.0-alpha.12](https://github.com/visulima/visulima/compare/@visulima/iso-locale@1.0.0-alpha.11...@visulima/iso-locale@1.0.0-alpha.12) (2026-06-13)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **iso-locale:** add typed codes, unified lookups and i18n names ([5c09bb6](https://github.com/visulima/visulima/commit/5c09bb61823c7997f034091f1cbeddc838d305a3))
|
|
6
|
+
|
|
7
|
+
### Code Refactoring
|
|
8
|
+
|
|
9
|
+
* **iso-locale:** apply eslint/prettier formatting cleanup ([d9875f0](https://github.com/visulima/visulima/commit/d9875f073d73d66f19ef9272b11694a80b3552be))
|
|
10
|
+
* **iso-locale:** derive literal unions from datasets ([c843246](https://github.com/visulima/visulima/commit/c843246db0a9b474cb68740b90b5718f6bc09d6e))
|
|
11
|
+
|
|
1
12
|
## @visulima/iso-locale [1.0.0-alpha.11](https://github.com/visulima/visulima/compare/@visulima/iso-locale@1.0.0-alpha.10...@visulima/iso-locale@1.0.0-alpha.11) (2026-06-04)
|
|
2
13
|
|
|
3
14
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -53,12 +53,16 @@ pnpm add @visulima/iso-locale
|
|
|
53
53
|
### Countries
|
|
54
54
|
|
|
55
55
|
```typescript
|
|
56
|
-
import { getByAlpha2, getCountryByName, getEmoji, getCallingCode, getLanguages } from "@visulima/iso-locale";
|
|
56
|
+
import { getByAlpha2, getCountry, getCountryByName, getCountryName, getEmoji, getCallingCode, getLanguages } from "@visulima/iso-locale";
|
|
57
57
|
|
|
58
58
|
// Get country by code
|
|
59
59
|
const country = getByAlpha2("US");
|
|
60
60
|
console.log(country.name); // "United States"
|
|
61
61
|
|
|
62
|
+
// Get country by ANY code format (alpha-2, alpha-3, or numeric)
|
|
63
|
+
console.log(getCountry("US")?.name); // "United States"
|
|
64
|
+
console.log(getCountry("USA")?.name); // "United States"
|
|
65
|
+
|
|
62
66
|
// Get country by name
|
|
63
67
|
const country2 = getCountryByName("United States");
|
|
64
68
|
|
|
@@ -70,6 +74,23 @@ console.log(getCallingCode("US")); // "+1"
|
|
|
70
74
|
|
|
71
75
|
// Get languages
|
|
72
76
|
console.log(getLanguages("US")); // ["eng"]
|
|
77
|
+
|
|
78
|
+
// Localized country name (uses the runtime Intl.DisplayNames API)
|
|
79
|
+
console.log(getCountryName("DE", "fr")); // "Allemagne"
|
|
80
|
+
console.log(getCountryName("US")); // "United States"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Strongly-typed codes
|
|
84
|
+
|
|
85
|
+
The country and currency code unions are derived directly from the bundled
|
|
86
|
+
datasets, so consumers get autocomplete and compile-time validation for free:
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import type { Alpha2Code, Alpha3Code, CurrencyCode } from "@visulima/iso-locale";
|
|
90
|
+
|
|
91
|
+
const region: Alpha2Code = "US"; // ✅
|
|
92
|
+
const wrong: Alpha2Code = "ZZ"; // ❌ compile error
|
|
93
|
+
const money: CurrencyCode = "EUR"; // ✅
|
|
73
94
|
```
|
|
74
95
|
|
|
75
96
|
### Currencies
|
|
@@ -145,8 +166,41 @@ const parsed = parseBCP47Tag("zh-Hant-TW");
|
|
|
145
166
|
console.log(parsed);
|
|
146
167
|
// { language: "zh", script: "Hant", country: "TW" }
|
|
147
168
|
|
|
148
|
-
// Generate BCP 47 tag
|
|
169
|
+
// Generate BCP 47 tag (script subtags are canonicalized to title case)
|
|
149
170
|
console.log(generateBCP47Tag("en", "US")); // "en-US"
|
|
171
|
+
console.log(generateBCP47Tag("zh", "TW", "hant")); // "zh-Hant-TW"
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Languages
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import { getCountriesByLanguage, getLanguageName } from "@visulima/iso-locale";
|
|
178
|
+
|
|
179
|
+
// Reverse lookup: which countries use a language (accepts ISO 639-1 or 639-3)
|
|
180
|
+
console.log(getCountriesByLanguage("de")); // ["AT", "BE", "CH", "DE", "LI", ...]
|
|
181
|
+
|
|
182
|
+
// Localized language name (uses the runtime Intl.DisplayNames API)
|
|
183
|
+
console.log(getLanguageName("de", "fr")); // "allemand"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Subpath entrypoints
|
|
187
|
+
|
|
188
|
+
Every domain is also available as a focused entrypoint, so you can import only
|
|
189
|
+
the dataset you need and let bundlers tree-shake the rest:
|
|
190
|
+
|
|
191
|
+
| Import | Contents |
|
|
192
|
+
| --------------------------------- | ------------------------------------------------------ |
|
|
193
|
+
| `@visulima/iso-locale` | Aggregate barrel re-exporting everything below |
|
|
194
|
+
| `@visulima/iso-locale/countries` | ISO 3166-1 country lookups + `Alpha2Code`/`Alpha3Code` |
|
|
195
|
+
| `@visulima/iso-locale/currencies` | ISO 4217 currency lookups + `CurrencyCode` |
|
|
196
|
+
| `@visulima/iso-locale/locale` | BCP 47 helpers, `getCurrency`, `getLanguageName` |
|
|
197
|
+
| `@visulima/iso-locale/regions` | UN M.49 region helpers |
|
|
198
|
+
| `@visulima/iso-locale/timezones` | IANA timezone helpers |
|
|
199
|
+
| `@visulima/iso-locale/types` | Shared TypeScript interfaces |
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
// Only pulls in the currency dataset, not countries/regions/timezones
|
|
203
|
+
import { getByCode, getSymbol } from "@visulima/iso-locale/currencies";
|
|
150
204
|
```
|
|
151
205
|
|
|
152
206
|
## Related
|