Automatic Translation of Country Names and Country Codes in R language
Why to Translate Country Names?
When working with multilingual websites, you need to convert country names to the language of the interface.
Also, you might want to store or deal with APIs that only understand country codes. Country codes usually are represented in three letters according to the ISO-3166–1-Alpha-3 encoding.
I was working on a multilingual project that deals with country names, we had to translate the country names in the interface to multi-lanauges and keep with each translation the correct country code, so we have consistent data when calling our APIs.
One of my colleague volunteered to do it manually, but I decided to do some research and see if I can do it automatically, and I found a very beautiful library in R language.
Translate Country Names in R
I found a beautiful package in R called countrycode, you can install the package in R as following:
install.packages("countrycode")
For more information about the library you can visit its repository in GitHub here.
Now let’s translate country name from German into Arabic: