Coder Social home page Coder Social logo

region-flags's Introduction

Introduction

This package is a collection of flags for geographic region and sub-region codes. The regions are based on the data from BCP 47 and selected sub-regions (US states, Canadian provinces and territories, and some sub-regions of Great Britain) are based on ISO 3166-2:US, ISO 3166-2:CA, and ISO-3166-2:GB.

Most people think of these regions from BCP 47 as country flags, but there are a few codes / flags that do not correspond to countries. The flags are in SVG and PNG format and named by their BCP 47 region code, which for countries is the same as ISO 3166-2 country code. In case of sub-regions, ISO 3166-2 is used for naming the files; e.g. US-DE.png is the flag of the State of Delaware.

The canonical way to get all BCP 47 region codes is to look for records in language-subtag-registry (which is downloaded from IANA Language Subtag Registry) with the following fields:

Type: region
Subtag: [A-Z]{2}
AND NOT Description: Private use
AND NOT Deprecated: .*

Regions not in that repository can be added to language-subtag-private. One such region has been added.

Some regions do not have their own flag. In such cases, they are symlinked to the best flag to represent them, which in most cases is the flag of their regional or political parent. These are listed in file ALIASES.

The sub-regions currently covered are:

  • US states and the District of Columbia
  • Canadian provinces and territories
  • Countries of England, Scotland, and Wales in Great Britain
  • The province Northern Ireland in Great Britain
  • Australia's states and its two self-governing internal territories
  • German states
  • Spain's regions
  • Mexico's states and one federal district

The flags are downloaded from Wikipedia. When Wikipedia flags were copyrighted, we worked we Wikipedia editors to either relicense them, or drew / sourced and uploaded new public-domain versions. In particular, the license for these flags were resolved for the initial import:

  • Montenegro
  • Nicaragua
  • Sint Maarten
  • Ascension Island
  • Lesotho
  • Kosovo

Scripts

  • The script regions.py lists all regions and some selected sub-regions with their metadata.
  • The script regions-wp.py shows the Wikipedia URL for the flag page.
  • The script missing.sh shows all such regions that we don't have flags for.
  • The script make-aliases.sh makes symlinks for regions that use flag of another region.
  • The script download-wp.sh downloads missing flags from Wikipedia and optionally you can generate optimized SVG and PNG versions (e.g., download-wp.sh true).
  • The script update.sh automatically regenerates all files and outputs optimized png.
  • The script convert.sh converts SVG to PNG with ability to specify Width or Height.

You can use the waveflag script from the Noto fonts project to wave PNG flags.

Requirements

Updating

If new regions are needed, update language-subtag-registry from IANA Language Subtag Registry, or add new regions to language-subtag-private before. Then update data/ALIASES and data/ALIASES-WP as needed.

If a specific flag on Wikipedia flag is under Creative Commons, work with Wikipedia editors to relicense it to public domain. If the flag is not explicitly marked public_domain but otherwise exempt from Copyright (typically, because of national laws), make a note of it in file COPYING.

To download missing flags, run download-wp.sh.

To update to latest flags from Wikipedia, delete the html, svg, and png directories, then run make-aliases.sh followed by download-wp.sh or you can use update.sh.

License

See file COPYING for details.

region-flags's People

Contributors

basaundi avatar behdad avatar behnam avatar jackocnr avatar jopejoe1 avatar poqdavid avatar savetherbtz avatar shervinafshar avatar skissane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

region-flags's Issues

WIPO ST.3 codes

ISO 3166/MA won’t assign (non-private) alpha-2 codes that are used by WIPO standard ST.3, cf. my Gist. These are codes for pan-national patent and intellectual property organizations. Most of them don’t have flags. Should they be added anyhow? (I think not.)

Symlinks don't work on Windows

Dang apparently Bower (and npm) ignore symlinks because they don't work on Windows.

Is there a way to get all the flags without symlinks?

Update list of regions to Unicode

Unicode now defines which regions are emoji flags. According to Mark Davis:


The valid flags used to be less clearly specified, but they are defined in the newest (v2.0) spec, http://unicode.org/reports/tr51/

ED-14. emoji flag sequence — A sequence of two Regional Indicator characters, where the corresponding ASCII characters are valid region sequences as specified by Unicode region subtags in [CLDR].

Those Unicode region subtags are based on BCP47, but have some small changes (including http://unicode.org/emoji/charts/full-emoji-list.html#1f1fd_1f1f0The valid flags used to be less clearly specified, but they are defined in the newest (v2.0) spec, http://unicode.org/reports/tr51/

ED-14. emoji flag sequence — A sequence of two Regional Indicator characters, where the corresponding ASCII characters are valid region sequences as specified by Unicode region subtags in [CLDR].

Those Unicode region subtags are based on BCP47, but have some small changes (including http://unicode.org/emoji/charts/full-emoji-list.html#1f1fd_1f1f0


We should switch to this instead of BCP 47 itself.

Overview of missing regions, states, territories, provinces and muncipalities (AR, AU, BQ, ES, FR, GE, NL, PT)

I know including every region ever is impossible, but I still wanted to provide an overview of what is missing.

ISO 3166-3 alpha-4 codes

Removed or deprecated ISO alpha-2 codes normally get alpha-4 codes in Part 3 of the standard. This is a way to support flags for “countries” that are no more (but had existed after 1949 or so), because they split up, merged with other countries or just changed their name significantly.

Should they be added?

Private-use codes Q…, X…

XK for Kosovo has been added. It’s being used by CLDR/Unicode, IMF and some others. There are some other private use alpha-2 codes that are (or could be) associated with flags within some implementations of ISO 3166-1. What are the criteria for adding such?

Better PNG compression

Consider switching to optipng-zopfli, as well as using pngquant. See usage in noto-emoji for the latter.

Add Russian and Belorussian opposition flags #StandWithUkraine

Russia and Belarus are currently totalitarian states where opposition is either driven out of the country, imprisoned, or outright killed. This lack of opposition is mainly to blame for the current war with Ukraine. It would be nice if we could help anti-war and anti-government oppositions by doing a non-disruptive region-flag addition.

The white-blue-white flag has become the symbol of the Russian anti-war protests in 2022. Sadly, there is no such flag yet. Adding new flags to Unicode is impossible (as described by Unicode's Emoji Proposal's Flags section) but, technically, Unicode's territory subdivisions can be used to add a white-blue-white flag without any changes to the Unicode standard itself. Russia's own Novgorod territory subdivision code can be used for this purpose: rungr.

Similarly, the white-red-white flag has become the de-facto symbol of the Belorussian protests in 2020.
In the Belorussian case, the situation is a bit trickier but still manageable: Minsk Region bymi code can be used. Alternatively, Colombia's Atlántico territory subdivision code flag can be added: coatl has a similar flag.

References
"Let's add a Belarusian national flag emoji (change.org)" https://www.change.org/p/unicode-consortium-let-s-add-a-belarusian-national-flag-emoji

Appendix A. Currently used workarounds.
Currently, the Russian opposition uses the following replacements:
🤍💙🤍, ⬜🟦⬜, ⚪🔵⚪, or sometimes ❌.
Similarly, the Belorussian opposition is resorting to the following sequences:
🤍❤️🤍, ⬜🟥⬜, ⚪🔴⚪.

Flags of US and UK subregions needed

Unicode is considering adding support for subregional flags.

My guess is the most in-demand are going to be the US states, and the four UK countries.

Spelling it out, it's actually 51 US subregions (including DC).

The list for US is at https://www.iso.org/obp/ui/#iso:code:3166:US (exclude those saying "outlying area", which already have a BCP47 code).

The list for UK is at https://www.iso.org/obp/ui/#iso:code:3166:GB. We only need the three countries and the one province:

GB-ENG: England
GB-NIR: Northern Ireland
GB-WLS: Wales
GB-SCT: Scotland

Add to NPM

Would you be interested in registering region-flags as a package on NPM? It's the most popular package manager for the JavaScript community, and adding region-flags would allow more devs to find and use it! Plus it's super easy.

There are two steps:

  1. You need a package.json file in the root dir, which I can prepare in a pull request
  2. You need to install npm and cd into the region-flags directory and run a couple of commands: npm adduser and follow instructions to create a new user for yourself, then npm publish to add region-flags to the npm index.

Let me know what you think, thanks!

Error: invalid tar file when downloading via NPM

Downloading this package via NPM results in the following error:

warn Error on download for github:behdad/region-flags
     Error: invalid tar file
         at Extract.Parse._startEntry (D:\projects\myproject\node_modules\tar\lib\parse.js:149:13)
         at Extract.Parse._process (D:\projects\myproject\node_modules\tar\lib\parse.js:131:12)
         at BlockStream.<anonymous> (D:\projects\myproject\node_modules\tar\lib\parse.js:47:8)
         at emitOne (events.js:96:13)
         at BlockStream.emit (events.js:188:7)
         at BlockStream._emitChunk (D:\projects\myproject\node_modules\block-stream\block-stream.js:145:10)
         at BlockStream.write (D:\projects\myproject\node_modules\block-stream\block-stream.js:45:10)
         at Extract.Parse.write (D:\projects\myproject\node_modules\tar\lib\parse.js:81:23)
         at Gunzip.ondata (_stream_readable.js:555:20)
         at emitOne (events.js:96:13)
         at Gunzip.emit (events.js:188:7)
         at readableAddChunk (_stream_readable.js:176:18)
         at Gunzip.Readable.push (_stream_readable.js:134:10)
         at Gunzip.Transform.push (_stream_transform.js:128:32)
         at Zlib.callback (zlib.js:609:14)

err  Error downloading github:behdad/region-flags.

Have you faced it, too? How to fix it?

Only few reserved country codes missing

I noticed this project contains a bunch of reserved country codes (see the Exceptional reservations section).

This repository contains flags for AC, CP, DG, EA, EU, IC, TA and UN. These are almost all reserved country codes, only a few are missing.

For example, the flag for the UK country code, which is listed on Wikipedia, is not in this repository. The same goes for SU.

For the sake of completeness I think these missing flags should be added.

Use sub-directories for sub-regions

Some ISO 3166-2 subregions for US and UK/GB are already included as US-##.{svg,png.html} and UK-###.*, respectively. BCP47 doesn’t care much about those, but UTR51.10+ does.

There are currently 5000ish subregion codes, many of which do not have a flag associated with them. Anyhow, this could easily get unwieldy in the directories if added in the future. Github Web “only” supports 1000 files per folder, if I remember correctly. I therefore suggest to move sub-region flags into sub-directories, i.e. effectively just replace the hyphen - in file names by a slash /.

Bower

Thanks for this amazing project - I'd like to use it for my popular International Telephone Input project. I was just wondering if you would consider publishing the project as a Bower package?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.