@vtex/country-codes
v1.1.2
Published
Utilities for managing country codes and translations
Downloads
448
Maintainers
Readme
country-codes
Country codes, translations and utilities
Setup
Through NPM:
$ npm install @vtex/country-codes
import toAlpha3 from '@vtex/country-codes/modules/toAlpha3'
Through vtex.io:
Add vtex.country-codes
to your manifest.json
dependencies
import { modules } from 'vtex.country-codes'
const { toAlpha2 } = modules
API
toAlpha2
Converts an ISOAlpha3
country code to its ISOAlpha2
version (such as BRA
-> BR
)
toAlpha3
Does the inverse procedure of the above function (BR
-> BRA
)
countryCodes
This entrypoint provides a list of all countries in the world, as an array where each country is also an array, whose first element is the alpha2
code and second element is the alpha3
code. You can use this together with the imported locales to display a full list of countries.
Locales
This library provides translations for country names in a large list of languages. The translation ID for a country is its ISOAlpha3
code preffixed by country
(example: **country.BRA**
). If using the vtex.io
app, the translations will be imported automatically. Otherwise, you should import the appropriate locale from the locales
folder.
Important: When using vtex.io
, if you do not import any component from the library, Render
will not copy the translations into your app. In such case, you need to import the special locales
entrypoint somewhere:
import 'vtex.country-codes/locales'
It is just an empty object and has no effect in your app.
Author: Gustavo Silva (@akaFTS), with codes and translations obtained from michaelwittig/node-i18n-iso-countries
This project is licensed under the MIT License.