michaelwittig/node-i18n-iso-countries

FR: Add flag emoji to countries, and countries.getCountries() to get a list of all properties

Closed this issue ยท 6 comments

Like this country package: https://github.com/OpenBookPrices/country-data
The flag emojis can fx. be used visually in a select.

Also getting a list of countries with both alpha2, alpha3, numeric, name and flag would be really nice.

If ever we step into that, I'm not sure emojis should be the way to go, there are still many compatibility issues :

The most universal/extensible way to do so would probably be relying on SVG data which is light and widespread.

But I'm guessing the real question is, do we want to diversify this library at this point? Some libraries do already exist for flags : https://www.npmjs.com/package/flag-icon-css

It might be more pertinent to focus the efforts around one exclusive feature, the translation, and let other libraries' contributors maintaining their own stuff.

It would be nice to collect more opinions on that. I would be glad to help anyway.

I agree with keeping this package focused on only one exclusive feature.

Speaking of country flags, I am making my own library for supporting those flags per source: ngx-nations.

Don't get confused by the name, it is like that because I was going to make only an angular wrapper lib of i18n-iso-countries but flag will be in their own packages with tree-shaking support ๐Ÿš€

I found this function somewhere (forgot where) and I'm currently using it in my project:

function countryToFlag(isoCode) {
    return typeof String.fromCodePoint !== 'undefined' ? isoCode
            .toUpperCase()
            .replace(/./g, (char) => String.fromCodePoint(char.charCodeAt(0) + 127397))
        : isoCode;
}

Wouldn't this solve the problem? Or am I missing something?

I found this function somewhere (forgot where) and I'm currently using it in my project:

function countryToFlag(isoCode) {
    return typeof String.fromCodePoint !== 'undefined' ? isoCode
            .toUpperCase()
            .replace(/./g, (char) => String.fromCodePoint(char.charCodeAt(0) + 127397))
        : isoCode;
}

Wouldn't this solve the problem? Or am I missing something?

You're partially right, this is a very good point that you raised, the only problem I see with such an emoji-based function is that not all platforms are compatible with emojis http://caniemoji.com/os-x/

This is also why many libraries are using SVG icons instead.
I guess it's just a matter of time to forget about this compatibility issue, as it's always been for other historical problems.

I found this function somewhere (forgot where) and I'm currently using it in my project:

function countryToFlag(isoCode) {
    return typeof String.fromCodePoint !== 'undefined' ? isoCode
            .toUpperCase()
            .replace(/./g, (char) => String.fromCodePoint(char.charCodeAt(0) + 127397))
        : isoCode;
}

Wouldn't this solve the problem? Or am I missing something?

You're partially right, this is a very good point that you raised, the only problem I see with such an emoji-based function is that not all platforms are compatible with emojis http://caniemoji.com/os-x/

This is also why many libraries are using SVG icons instead.
I guess it's just a matter of time to forget about this compatibility issue, as it's always been for other historical problems.

Right, I see. Thank you very much for the quick response!

OS X 10.10 and Windows 8.1 which both support Emoji in all browser were released more than 8 years ago