Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Kosovo #793

Open
melder opened this issue Feb 4, 2023 · 7 comments
Open

Missing Kosovo #793

melder opened this issue Feb 4, 2023 · 7 comments

Comments

@melder
Copy link

melder commented Feb 4, 2023

Not sure why you are missing Kosovo:

From
https://countrycode.org/kosovo
Kosovo | 383 | XK / XKX | 1,800,000 | 10,887 | 7.15 Billion

I use this library to rate limit requests from countries and essentially got DDOSed by Kosovo since it was missing. Had to manually block Kosovo IP range.

Thanks

@pmor
Copy link
Member

pmor commented Feb 4, 2023

Hi @melder,

The issue with Kosovo is that there is no ISO3166 code assigned at this time. Code XK is an unofficial code that is widely used until an ISO code is assigned, see https://en.wikipedia.org/wiki/XK_(user_assigned_code) for some more info.

The workaround we've recommended is to load custom data, something along these lines, with the attributes that you require:

ISO3166::Data.register(
  alpha2: "XK",
  alpha3: "XKX",
  name: "Kosovo",
  currency: "EUR",
  translations: {
    "en" => "Kosovo",
  },
)

@melder
Copy link
Author

melder commented Feb 4, 2023

Ok will do. Any other disputed territories that ISO3166 does not recognize but have unofficial country codes? I couldn't find anything while googling. I'm genuinely surprised about Kosovo as it has been independent for 15 years already. Even Palestine, who are not a sovereign entity are recognized on ISO3166? Very strange.

@maxigs
Copy link

maxigs commented Feb 5, 2023

FYI:
I just stumbled over this issue as well. Additionally, when adding the new country via ..register however something with the translations seems to go wrong, and it only shows the fallback english for ALL countries. I haven't narrowed the issue down yet, might as well be in country_select gem.

When adding the register in an initializer the ISO3166::Country objects loose the translations. But ISO3166::Country.translations keeps them.

As a workaround i monkeypatched the output of country_select gem like this:

ISO3166::Data.register(
  alpha2: "XK",
  alpha3: "XKX",
  name: "Kosovo",
  currency: "EUR",
  translations: {
    "en" => "Kosovo",
    "de" => "Kosovo",
  },
)

CountrySelect::FORMATS[:default] = lambda do |country|
  ISO3166::Country.translations('de')[country.alpha2]
end

@pmor
Copy link
Member

pmor commented Feb 8, 2023

@maxigs I'll look into it, thanks for the report.

@melder As far as I'm aware, Kosovo is the only country in this situation. There are other countries with limited recognition (https://en.wikipedia.org/wiki/List_of_states_with_limited_recognition) that have ISO3166 codes, such as Palestine and Western Sahara, and there are those that don't have ISO3166 codes, but are not widely recognised as independent countries, so there hasn't been an issue.

@zhuniqiabedin
Copy link

Did something happened here ?
It is been almost one year and this thread is still opened and nothing happened.

@pmor
Copy link
Member

pmor commented Feb 7, 2024

As I mentioned in my initial reply to this issue, Kosovo does not have an ISO3166 code assigned to it. Until that happens, you can manually add it as a custom country.

I've left this issue open because it has been raised several times in the past, and it's more visible as an open issue.

@pinge
Copy link

pinge commented Mar 29, 2024

@pmor thank you for your work and for leaving this issue open!

Here's the nearly complete data for Republic of Kosovo / XK if anyone needs it:

ISO3166::Data.register(
  alpha2: "XK",
  alpha3: "XKX",
  continent: "Europe",
  country_code: "383",
  currency_code: "EUR",
  distance_unit: "KM",
  gec: "KV",
  geo: {
    latitude: 42.5833,
    longitude: 21.0001,
    max_latitude: 43.139,
    max_longitude: 21.835,
    min_latitude: 41.877,
    min_longitude: 19.949,
    bounds: {
      northeast: {
        lat: 41.877,
        lng: 19.949,
      },
      southwest: {
        lat: 43.139,
        lng: 21.835,
      }
    }
  },
  international_prefix: "00",
  ioc: "KOS",
  iso_long_name: "Republic of Kosovo",
  iso_short_name: "Kosovo",
  languages_official: ["sq", "sr"],
  languages_spoken: ["sq", "sr"],
  nationality: "Kosovar",
  postal_code: true,
  postal_code_format: "\\d{5}",
  region: "Europe",
  start_of_week: "monday",
  subregion: "Southern Europe",
  unofficial_names: ["Kosovo", "Kosova", "Косово"],
  world_region: "EMEA",
  translations: {
    "en" => "Kosovo",
  },
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants