How to get language and region names for various translations in JS?
โ2 min read
- Internationalization
- Intl
- Translating websites

Let's say you want to your current user's region name in their native language
For English it would be 'United States', for French 'รtats-Unis', for German 'Vereinigte Staaten' and so on.
So what to do now?
Create an object with each translation there is? Poor idea.
Ask GPT-4 API to translate items? Better, but also far from ideal.
Use the Intl
Intl nowadays consists of curated map of translations for each locale. For following items language
, region
, script
, currency
, calendar
, and dateTimeField
you can get a well made list of translations without using third party at all.
Get regions in user's browser language
Get regions in Spanish
Get currencies in Spanish
Translate smart
Not everybody is familiar with the Intl library and it is indeed a very powerful tool to make our app accessible for anyone in the world. Have a great day, see you on the next one ๐.