Project

llaxta

0.0
No commit activity in last 3 years
No release in over 3 years
Translate ISO 3166-1 codes to Country names given a locale
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.2
~> 0.14.1
~> 3.10
~> 1.0
 Project Readme

Get the name of any of the 249 countries listed in English US, Spanish, Brazilian Portuguese and/or Simplified Chinese.

Usage

Llaxta.t receives the country Alpha2 code and the locale corresponding to the language in which the country name is going to be shown.

Llaxta.t("CH", "en_us") # => "Switzerland"
Llaxta.t("CH", "es")    # => "Suiza"
Llaxta.t("CH", "pt_br") # => "Suíça"
Llaxta.t("CH", "zh_cn") # => "瑞士"

For convenience, and because there's only 4 supported locales, you can use the short version of the languages English (us), Portuguese (br) and Chinese (cn):

Llaxta.t("CH", "us") # => "Switzerland"
Llaxta.t("CH", "br") # => "Suíça"
Llaxta.t("CH", "cn") # => "瑞士"

Llaxta.alpha2 receives a country name and a locale, and returns the country alpha2 if it can be found through the given country name for the given locale.

Llaxta.alpha2("Etiópia", "br")    # => "ET"
Llaxta.alpha2("埃塞俄比亚", "cn") # => "ET"
Llaxta.alpha2("Etiopía", "es")    # => "ET"
Llaxta.alpha2("Ethiopia", "us")   # => "ET"