4 releases
0.2.0 | Nov 27, 2021 |
---|---|
0.1.2 | Oct 26, 2020 |
0.1.1 | Oct 26, 2020 |
0.1.0 | Oct 26, 2020 |
#148 in Internationalization (i18n)
190 downloads per month
24KB
375 lines
country-emoji
Converts between country names, ISO 3166-1 codes and flag emojis.
Usage
use country_emoji::{flag, code, name, countries};
flag("CL")
// ~> ๐จ๐ฑ
code("๐จ๐ฆ")
// ~> CA
name("๐ถ๐ฆ")
// ~> Qatar
// can extract name from stringโฆ
flag("Taiwan number one!")
// ~> ๐น๐ผ
// โฆbut only if there"s no ambiguity
flag("Congo and Burma")
// ~> undefined
flag("Republic of Tanzania")
// ~> ๐น๐ฟ
flag("Tanzania, United Republic of")
// ~> ๐น๐ฟ
code("Australia")
// ~> AU
code("UAE")
// ~> AE
name("AE")
// ~> United Arab Emirates
code("UK")
// ~> GB
Don't want Rust?
Check out the following:
- JavaScript: country-emoji
- Swift: SwiftFlags (ref: #16)
Bugs and feedback
If you discover a bug please report it here. Express gratitude here.
Mail me at leodutra.br+foss@gmail.com, or on twitter @leodutra.
Credits
This library is based on the work of two existing library:
- country-emoji, available for JavaScript
- flag-emoji-from-country-code, a great snippet to get the emoji flag from an ISO 3166-1 region code
Thanks guys for your work!
License
MIT @ Leo Dutra
Dependencies
~2.2โ3MB
~55K SLoC