countrynormalizer 0.2.8 β†’ 0.3.0

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/README.md CHANGED
@@ -65,6 +65,8 @@ The returned country structure will match the `AllCountryFields` type and look l
65
65
  demonym_male: "American",
66
66
  demonym_female: "American",
67
67
  gendered_demonym: true,
68
+ official_languages: ["en"],
69
+ lang_defacto: false,
68
70
  tld: ".us",
69
71
  flag_emoji: "πŸ‡ΊπŸ‡Έ",
70
72
  calling_code: ["1"],
@@ -76,7 +78,12 @@ The returned country structure will match the `AllCountryFields` type and look l
76
78
 
77
79
  You can use `findAllMatchedCountries(needle: string | number): AllCountryFields[]` to get all countries that match a particular data point.
78
80
 
79
- Certain pieces of country data are not unique but still routinely need to be searched for.
81
+ Certain pieces of country data are not unique but still routinely need to be searched for. In addition to all unique fields, this function also searches:
82
+
83
+ - `calling_code` β€” phone calling codes (e.g. `"+1"`, `"44"`)
84
+ - `continent` β€” continent name (e.g. `"Asia"`)
85
+ - `demonym_male` / `demonym_female` β€” demonyms (e.g. `"Canadian"`)
86
+ - `official_languages` β€” ISO 639 language codes (e.g. `"fr"`, `"es"`)
80
87
 
81
88
  A common example of this is calling codes. Most of North America uses the `+1` calling code block. Using a `needle` value of `1` or `+1` will return an array of country data like...
82
89
 
@@ -91,6 +98,8 @@ A common example of this is calling codes. Most of North America uses the `+1` c
91
98
  "demonym_male": "American",
92
99
  "demonym_female": "American",
93
100
  "gendered_demonym": true,
101
+ "official_languages": ["en"],
102
+ "lang_defacto": false,
94
103
  "tld": ".us",
95
104
  "flag_emoji": "πŸ‡ΊπŸ‡Έ",
96
105
  "calling_code": [
@@ -108,6 +117,8 @@ A common example of this is calling codes. Most of North America uses the `+1` c
108
117
  "demonym_male": "United States Minor Outlying Islander",
109
118
  "demonym_female": "United States Minor Outlying Islander",
110
119
  "gendered_demonym": true,
120
+ "official_languages": ["en"],
121
+ "lang_defacto": false,
111
122
  "tld": ".um",
112
123
  "flag_emoji": "πŸ‡ΊπŸ‡²",
113
124
  "calling_code": [
@@ -125,6 +136,8 @@ A common example of this is calling codes. Most of North America uses the `+1` c
125
136
  "demonym_male": "Canadian",
126
137
  "demonym_female": "Canadian",
127
138
  "gendered_demonym": true,
139
+ "official_languages": ["en", "fr"],
140
+ "lang_defacto": false,
128
141
  "tld": ".ca",
129
142
  "flag_emoji": "πŸ‡¨πŸ‡¦",
130
143
  "calling_code": [
@@ -137,6 +150,8 @@ A common example of this is calling codes. Most of North America uses the `+1` c
137
150
 
138
151
  Another use case for this could be if your app has a region-based country selection and you needed all countries in Asia. You could perform a `findAllMatchedCountries('asia')` and get all countries in Asia.
139
152
 
153
+ You can also search by ISO 639 language code to find all countries where that language is official (or de facto official). For example, `findAllMatchedCountries('fr')` returns all countries where French is an official language β€” France, Canada, Switzerland, and many others.
154
+
140
155
  This function still supports singular lookup. Entering something like `findAllMatchedCountries('GB')` will return a single item array like...
141
156
 
142
157
  ```
@@ -150,6 +165,8 @@ This function still supports singular lookup. Entering something like `findAllMa
150
165
  "demonym_male": "British",
151
166
  "demonym_female": "British",
152
167
  "gendered_demonym": true,
168
+ "official_languages": ["en"],
169
+ "lang_defacto": false,
153
170
  "tld": ".gb",
154
171
  "flag_emoji": "πŸ‡¬πŸ‡§",
155
172
  "calling_code": [
@@ -173,7 +190,9 @@ In order to keep a smaller object available to work with and for tree-shaking co
173
190
  "flag_emoji": "πŸ‡¬πŸ‡³",
174
191
  "calling_code": [
175
192
  "224"
176
- ]
193
+ ],
194
+ "official_languages": ["fr"],
195
+ "lang_defacto": false
177
196
  }
178
197
  ```
179
198
 
@@ -267,6 +286,16 @@ This data is compiled from a wide array of sources. To give transparency to this
267
286
  - - https://en.wikipedia.org/wiki/List_of_telephone_country_codes
268
287
  - - https://www.countrycode.org/
269
288
  - continent: ChatGPT deep research compiled list asking to align all ISO Alpha 3 country codes to their continent.
289
+ - official_languages: ISO 639 language codes for each country's officially recognized languages. Data sourced primarily from:
290
+ - https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes
291
+ - https://en.wikipedia.org/wiki/List_of_official_languages_by_country_and_territory
292
+ - lang_defacto: A boolean flag indicating whether the `official_languages` entries are de facto rather than formally government-recognized. When `true`, the country has no constitutionally or legally designated official language β€” the listed language(s) represent the dominant language(s) in practice.
293
+
294
+ ### Language Data Notes
295
+
296
+ **Montenegro (`ME`):** Montenegrin is not part of the ISO 639 standard β€” it emerged as a distinct designation following political changes in the region and is not universally recognized as a separate language by the international standards body. Serbian (`sr`) is used as a pragmatic substitute, as it is the closest ISO 639 code for the language most widely spoken in Montenegro.
297
+
298
+ **Antarctica (`AQ`):** Antarctica is not a sovereign country and has no official language. It is governed under the Antarctic Treaty System, with many nations maintaining research bases there. English is set as the language (`lang_defacto: true`) because it functions as the primary working language of the international scientific community present on the continent, and most treaty nations speak English officially or as a common second language.
270
299
 
271
300
  ## To-Do List:
272
301