country_name

Version, currently 0.1.02 versions

github.com/arcage/country_name.cr

No description declared in shard.yml.

1 stars
0 dependents
License: MIT

Nothing has been indexed for 0.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  country_name:
    github: arcage/country_name.cr
    version: ~> 0.1.0

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.1.0. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

Country Name utils for Crystal

Lookups country name from ISO 3166-1(Alpha 2) country code.

Installation

  1. Add the dependency to your shard.yml:

    dependencies: 
      country_name: 
        github: arcage/country_name.cr
  2. Run shards install

Usage

require "country_name"

# Basic lookup(case insensitive)
CountryName.from_country_code("jp") #=> "Japan"

# Specify language
CountryName.from_country_code("jp", "ja") #=> "日本"

# Set default language
CountryName.default_lnag = "ja"
CountryName.from_country_code("jp") #=> "日本"

# An exception is raised when the code doesn't exist.
CountryName.from_country_code("xx")
#>> Unhandled exception: Country code "xx" not found. (CountryName::Error)

# from_country_code? method returns nil when the code doesn't exist.
CountryName.from_country_code?("xx") #=> nil

Supported languages

Afrikaans(af), Akan(ak), Amharic(am), Arabic(ar), Assamese(as), Azerbaijani(az), Belarusian(be), Bulgarian(bg), Bambara(bm), Bengali(bn), Tibetan(bo), Breton(br), Bosnian(bs), Catalan/Valencian(ca), Chechen(ce), Czech(cs), Welsh(cy), Danish(da), German(de), Dzongkha(dz), Ewe(ee), Greek(Modern)(el), English(en), Esperanto(eo), Spanish/Castilian(es), Estonian(et), Basque(eu), Persian(fa), Fulah(ff), Finnish(fi), Faroese(fo), French(fr), Western Frisian(fy), Irish(ga), Gaelic/Scottish Gaelic(gd), Galician(gl), Gujarati(gu), Manx(gv), Hausa(ha), Hebrew(he), Hindi(hi), Croatian(hr), Hungarian(hu), Armenian(hy), Interlingua(International Auxiliary Language Association)(ia), Indonesian(id), Igbo(ig), Sichuan Yi/Nuosu(ii), Icelandic(is), Italian(it), Japanese(ja), Javanese(jv), Georgian(ka), Kikuyu/Gikuyu(ki), Kazakh(kk), Kalaallisut/Greenlandic(kl), Central Khmer(km), Kannada(kn), Korean(ko), Kashmiri(ks), Kurdish(ku), Cornish(kw), Kirghiz/Kyrgyz(ky), Luxembourgish/Letzeburgesch(lb), Ganda(lg), Lingala(ln), Lao(lo), Lithuanian(lt), Luba-Katanga(lu), Latvian(lv), Malagasy(mg), Maori(mi), Macedonian(mk), Malayalam(ml), Mongolian(mn), Marathi(mr), Malay(ms), Maltese(mt), Burmese(my), Norwegian Bokmål(nb), North Ndebele(nd), Nepali(ne), Dutch/Flemish(nl), Norwegian Nynorsk(nn), Norwegian(no), Oromo(om), Oriya(or), Ossetian/Ossetic(os), Panjabi/Punjabi(pa), Polish(pl), Pashto/Pushto(ps), Portuguese(pt), Quechua(qu), Romansh(rm), Rundi(rn), Romanian/Moldavian/Moldovan(ro), Russian(ru), Kinyarwanda(rw), Sindhi(sd), Northern Sami(se), Sango(sg), Serbo-Croatian(sh), Sinhala/Sinhalese(si), Slovak(sk), Slovenian(sl), Shona(sn), Somali(so), Albanian(sq), Serbian(sr), Swedish(sv), Swahili(sw), Tamil(ta), Telugu(te), Tajik(tg), Thai(th), Tigrinya(ti), Turkmen(tk), Tagalog(tl), Tonga(Tonga Islands)(to), Turkish(tr), Tatar(tt), Uighur/Uyghur(ug), Ukrainian(uk), Urdu(ur), Uzbek(uz), Vietnamese(vi), Wolof(wo), Xhosa(xh), Yiddish(yi), Yoruba(yo), Chinese(zh), Zulu(zu)

Special thanks

This library uses conversion tables(ISO 3166-1 alpha-2 country codes to country names) provided by umpirsky/country-list © Saša Stamenković umpirsky@gmail.com(license is here).

It supports many kinds of file formats(CSV, JSON, YAML, etc...) and many kinds of languages.

I sincerely respect this great work.

Contributors