i18n-countries-continents 1.0.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/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/README.md +281 -0
- package/dist/data/cities.json +40102 -0
- package/dist/data/continents.json +72 -0
- package/dist/data/countries.json +3002 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/services/cities/get-cities.d.ts +7 -0
- package/dist/services/cities/get-cities.d.ts.map +1 -0
- package/dist/services/cities/get-cities.js +8 -0
- package/dist/services/cities/get-cities.js.map +1 -0
- package/dist/services/cities/get-city-name.d.ts +3 -0
- package/dist/services/cities/get-city-name.d.ts.map +1 -0
- package/dist/services/cities/get-city-name.js +8 -0
- package/dist/services/cities/get-city-name.js.map +1 -0
- package/dist/services/cities/index.d.ts +5 -0
- package/dist/services/cities/index.d.ts.map +1 -0
- package/dist/services/cities/index.js +4 -0
- package/dist/services/cities/index.js.map +1 -0
- package/dist/services/cities/search-cities.d.ts +7 -0
- package/dist/services/cities/search-cities.d.ts.map +1 -0
- package/dist/services/cities/search-cities.js +21 -0
- package/dist/services/cities/search-cities.js.map +1 -0
- package/dist/services/continents/get-continent-name.d.ts +3 -0
- package/dist/services/continents/get-continent-name.d.ts.map +1 -0
- package/dist/services/continents/get-continent-name.js +8 -0
- package/dist/services/continents/get-continent-name.js.map +1 -0
- package/dist/services/continents/get-continents.d.ts +7 -0
- package/dist/services/continents/get-continents.d.ts.map +1 -0
- package/dist/services/continents/get-continents.js +8 -0
- package/dist/services/continents/get-continents.js.map +1 -0
- package/dist/services/continents/index.d.ts +4 -0
- package/dist/services/continents/index.d.ts.map +1 -0
- package/dist/services/continents/index.js +3 -0
- package/dist/services/continents/index.js.map +1 -0
- package/dist/services/countries/get-continent-by-country.d.ts +2 -0
- package/dist/services/countries/get-continent-by-country.d.ts.map +1 -0
- package/dist/services/countries/get-continent-by-country.js +6 -0
- package/dist/services/countries/get-continent-by-country.js.map +1 -0
- package/dist/services/countries/get-countries.d.ts +9 -0
- package/dist/services/countries/get-countries.d.ts.map +1 -0
- package/dist/services/countries/get-countries.js +10 -0
- package/dist/services/countries/get-countries.js.map +1 -0
- package/dist/services/countries/get-country-flag.d.ts +2 -0
- package/dist/services/countries/get-country-flag.d.ts.map +1 -0
- package/dist/services/countries/get-country-flag.js +6 -0
- package/dist/services/countries/get-country-flag.js.map +1 -0
- package/dist/services/countries/get-country-name.d.ts +3 -0
- package/dist/services/countries/get-country-name.d.ts.map +1 -0
- package/dist/services/countries/get-country-name.js +6 -0
- package/dist/services/countries/get-country-name.js.map +1 -0
- package/dist/services/countries/index.d.ts +6 -0
- package/dist/services/countries/index.d.ts.map +1 -0
- package/dist/services/countries/index.js +5 -0
- package/dist/services/countries/index.js.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +5 -0
- package/dist/services/index.js.map +1 -0
- package/dist/utils/constants.d.ts +2 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +2 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/types.d.ts +9 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +86 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2025-11-05
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release with **250 countries** and **7 continents**
|
|
12
|
+
- Get country names in multiple languages (en, es, fr, ar, nl)
|
|
13
|
+
- Get continent names in multiple languages
|
|
14
|
+
- Look up continent by country code
|
|
15
|
+
- Support for React, Angular, Vue, Svelte, Node.js, and plain JavaScript
|
|
16
|
+
- Full TypeScript support with type definitions
|
|
17
|
+
- ES6 and CommonJS module support
|
|
18
|
+
- JSON data format for easy maintenance and updates
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
- `getCountryName(code, language)` - Get country name by code
|
|
22
|
+
- `getCountries(language)` - List all countries in a specific language
|
|
23
|
+
- `getContinentByCountry(countryCode)` - Get continent code by country
|
|
24
|
+
- `getContinentName(code, language)` - Get continent name by code
|
|
25
|
+
- `getContinents(language)` - List all continents in a specific language
|
|
26
|
+
|
|
27
|
+
### Data Coverage
|
|
28
|
+
- **250 countries** across all continents
|
|
29
|
+
- **7 continents** (complete coverage)
|
|
30
|
+
- **5 languages** with 100% translation coverage
|
|
31
|
+
- All countries use ISO 3166-1 alpha-2 codes
|
|
32
|
+
- Proper continent mapping for all countries
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Aissam El Houref
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
# i18n-countries-continents
|
|
2
|
+
|
|
3
|
+
Get country, continent, and city names in different languages. **250 countries**, **7 continents**, and **4,010 cities** with full translations in 5 languages. Works in React, Angular, Vue, Node.js, and any JavaScript environment.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install i18n-countries-continents
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- 🌍 **250 countries** - Complete coverage of all world countries
|
|
14
|
+
- � **Country flags** - Flag emoji for every country
|
|
15
|
+
- �🗺️ **7 continents** - All continents included
|
|
16
|
+
- 🏙️ **4,010 cities** - Major cities from around the world
|
|
17
|
+
- 🌐 **5 languages** - English, Spanish, French, Arabic, Dutch (100% coverage)
|
|
18
|
+
- 📦 **Zero dependencies** - Lightweight and fast
|
|
19
|
+
- 🔤 **ISO 3166-1 codes** - Standard country codes
|
|
20
|
+
- 💪 **TypeScript** - Full type definitions included
|
|
21
|
+
- ⚡ **Tree-shakeable** - Import only what you need
|
|
22
|
+
- 🎯 Works with React, Angular, Vue, Svelte, Node.js, and plain JavaScript
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### 1. Get a country name in a specific language
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { getCountryName } from 'i18n-countries-continents';
|
|
30
|
+
|
|
31
|
+
console.log(getCountryName('FR', 'fr')); // France
|
|
32
|
+
console.log(getCountryName('FR', 'es')); // Francia
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. Get a country flag
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import { getCountryFlag } from 'i18n-countries-continents';
|
|
39
|
+
|
|
40
|
+
console.log(getCountryFlag('US')); // 🇺🇸
|
|
41
|
+
console.log(getCountryFlag('FR')); // 🇫🇷
|
|
42
|
+
console.log(getCountryFlag('JP')); // 🇯🇵
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 3. List all countries in a language
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
import { getCountries } from 'i18n-countries-continents';
|
|
49
|
+
|
|
50
|
+
const countries = getCountries('en');
|
|
51
|
+
countries.forEach(c => console.log(c.flag, c.code, c.name));
|
|
52
|
+
// Output: 🇺🇸 US United States
|
|
53
|
+
// 🇫🇷 FR France
|
|
54
|
+
// ...
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 4. Get a continent code by country code
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
import { getContinentByCountry } from 'i18n-countries-continents';
|
|
61
|
+
|
|
62
|
+
console.log(getContinentByCountry('US')); // "NA"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 5. Get a continent name in a specific language
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
import { getContinentName } from 'i18n-countries-continents';
|
|
69
|
+
|
|
70
|
+
console.log(getContinentName('EU', 'es')); // Europa
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 6. List all continents in a language
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
import { getContinents } from 'i18n-countries-continents';
|
|
77
|
+
|
|
78
|
+
const continents = getContinents('fr');
|
|
79
|
+
continents.forEach(c => console.log(c.code, c.name));
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 7. Get a city name in a specific language
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
import { getCityName } from 'i18n-countries-continents';
|
|
86
|
+
|
|
87
|
+
console.log(getCityName('Paris', 'fr')); // Paris
|
|
88
|
+
console.log(getCityName('Paris', 'ar')); // باريس
|
|
89
|
+
console.log(getCityName('London', 'fr')); // Londres
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 8. List all cities in a language
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
import { getCities } from 'i18n-countries-continents';
|
|
96
|
+
|
|
97
|
+
const cities = getCities('es');
|
|
98
|
+
cities.forEach(c => console.log(c.name, '→', c.translatedName));
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 9. Search for cities
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
import { searchCities } from 'i18n-countries-continents';
|
|
105
|
+
|
|
106
|
+
// Search for cities containing "york" in English
|
|
107
|
+
const results = searchCities('york', 'en', 5);
|
|
108
|
+
results.forEach(c => console.log(c.name, '→', c.translatedName));
|
|
109
|
+
|
|
110
|
+
// Output:
|
|
111
|
+
// East York → East York
|
|
112
|
+
// New York → New York
|
|
113
|
+
// North York → North York
|
|
114
|
+
// York → York
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Framework Usage
|
|
120
|
+
|
|
121
|
+
### React
|
|
122
|
+
|
|
123
|
+
```jsx
|
|
124
|
+
import { getCountries } from 'i18n-countries-continents';
|
|
125
|
+
|
|
126
|
+
function CountryList() {
|
|
127
|
+
const countries = getCountries('fr');
|
|
128
|
+
return (
|
|
129
|
+
<ul>
|
|
130
|
+
{countries.map(c => <li key={c.code}>{c.name}</li>)}
|
|
131
|
+
</ul>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Angular
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { getCountries } from 'i18n-countries-continents';
|
|
140
|
+
|
|
141
|
+
@Component({ /* ... */ })
|
|
142
|
+
export class MyComponent {
|
|
143
|
+
countries = getCountries('es');
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Vue
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
import { getCountries } from 'i18n-countries-continents';
|
|
151
|
+
|
|
152
|
+
export default {
|
|
153
|
+
data() {
|
|
154
|
+
return {
|
|
155
|
+
countries: getCountries('en')
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Node.js
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
const { getContinentByCountry, getContinentName } = require('i18n-countries-continents');
|
|
165
|
+
|
|
166
|
+
const continentCode = getContinentByCountry('US');
|
|
167
|
+
const continentName = getContinentName(continentCode, 'es');
|
|
168
|
+
console.log(continentName); // Norteamérica
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Data Coverage
|
|
176
|
+
|
|
177
|
+
### Countries: 250
|
|
178
|
+
- **Africa**: 58 countries
|
|
179
|
+
- **Antarctica**: 5 territories
|
|
180
|
+
- **Asia**: 53 countries
|
|
181
|
+
- **Europe**: 53 countries
|
|
182
|
+
- **North America**: 41 countries
|
|
183
|
+
- **Oceania**: 26 countries
|
|
184
|
+
- **South America**: 14 countries
|
|
185
|
+
|
|
186
|
+
### Continents: 7
|
|
187
|
+
All continents fully covered with translations in all 5 languages.
|
|
188
|
+
|
|
189
|
+
### Cities: 4,010
|
|
190
|
+
Major cities from around the world including:
|
|
191
|
+
- Capital cities
|
|
192
|
+
- Major metropolitan areas
|
|
193
|
+
- Important economic centers
|
|
194
|
+
- Cultural landmarks
|
|
195
|
+
|
|
196
|
+
### Languages: 5
|
|
197
|
+
- English (en) - 100%
|
|
198
|
+
- Spanish (es) - 100%
|
|
199
|
+
- French (fr) - 100%
|
|
200
|
+
- Arabic (ar) - 100%
|
|
201
|
+
- Dutch (nl) - 100%
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## API Reference
|
|
206
|
+
|
|
207
|
+
### Country Services
|
|
208
|
+
|
|
209
|
+
#### `getCountryName(code: string, language?: SupportedLanguage): string | undefined`
|
|
210
|
+
Get the name of a country by its ISO 3166-1 alpha-2 code.
|
|
211
|
+
|
|
212
|
+
#### `getCountryFlag(code: string): string | undefined`
|
|
213
|
+
Get the flag emoji for a country by its ISO 3166-1 alpha-2 code.
|
|
214
|
+
|
|
215
|
+
#### `getCountries(language?: SupportedLanguage): Country[]`
|
|
216
|
+
Get all countries with their names and flags in the specified language.
|
|
217
|
+
|
|
218
|
+
#### `getContinentByCountry(code: string): string | undefined`
|
|
219
|
+
Get the continent code for a country.
|
|
220
|
+
|
|
221
|
+
### Continent Services
|
|
222
|
+
|
|
223
|
+
#### `getContinentName(code: string, language?: SupportedLanguage): string | undefined`
|
|
224
|
+
Get the name of a continent by its code.
|
|
225
|
+
|
|
226
|
+
#### `getContinents(language?: SupportedLanguage): Continent[]`
|
|
227
|
+
Get all continents with their names in the specified language.
|
|
228
|
+
|
|
229
|
+
### City Services
|
|
230
|
+
|
|
231
|
+
#### `getCityName(cityName: string, language?: SupportedLanguage): string | undefined`
|
|
232
|
+
Get the translated name of a city.
|
|
233
|
+
|
|
234
|
+
#### `getCities(language?: SupportedLanguage): City[]`
|
|
235
|
+
Get all cities with their names in the specified language.
|
|
236
|
+
|
|
237
|
+
#### `searchCities(query: string, language?: SupportedLanguage, limit?: number): City[]`
|
|
238
|
+
Search for cities by name. Returns up to `limit` results (default: 10).
|
|
239
|
+
|
|
240
|
+
### Types
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
type SupportedLanguage = 'en' | 'es' | 'fr' | 'ar' | 'nl';
|
|
244
|
+
|
|
245
|
+
interface Country {
|
|
246
|
+
code: string;
|
|
247
|
+
continent: string;
|
|
248
|
+
name: string;
|
|
249
|
+
flag: string;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
interface Continent {
|
|
253
|
+
code: string;
|
|
254
|
+
name: string;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
interface City {
|
|
258
|
+
name: string;
|
|
259
|
+
translatedName: string;
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Data Format
|
|
266
|
+
|
|
267
|
+
Country, continent, and city data is stored in JSON format in `src/data/` directory. This makes it easy to:
|
|
268
|
+
- Add new data or translations
|
|
269
|
+
- Update existing data
|
|
270
|
+
- Contribute via pull requests
|
|
271
|
+
- Parse and validate programmatically
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## License
|
|
278
|
+
|
|
279
|
+
MIT
|
|
280
|
+
|
|
281
|
+
---
|