-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Replace country-regex with i18n-iso-countries #7366
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
base: master
Are you sure you want to change the base?
Conversation
thanks @dimitrov570 - I'll see if we can get this into the 3.1 release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! I left a few comments. Could you please merge master and handle the merge conflicts?
@gvwilson there are 6 codes removed from the new package. Would this count as a breaking change? The countries don't exist anymore.
Code | Country |
---|---|
ANT | Netherlands Antilles |
CSK | Czechoslovakia |
DDR | German Democratic Republic |
EAZ | Zanzibar |
YMD | South Yemen |
YUG | Yugoslavia |
draftlogs/7366_change.md
Outdated
@@ -0,0 +1 @@ | |||
- Replace country-regex with i18n-iso-countries [[#7366](https://github.com/plotly/plotly.js/pull/7366)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Replace country-regex with i18n-iso-countries [[#7366](https://github.com/plotly/plotly.js/pull/7366)] | |
- Replace country-regex package with i18n-iso-countries [[#7366](https://github.com/plotly/plotly.js/pull/7366)] |
src/lib/geo_location_utils.js
Outdated
@@ -12,8 +11,8 @@ var isPlainObject = require('./is_plain_object'); | |||
var nestedProperty = require('./nested_property'); | |||
var polygon = require('./polygon'); | |||
|
|||
// make list of all country iso3 ids from at runtime | |||
var countryIds = Object.keys(countryRegex); | |||
const countries = require("i18n-iso-countries"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please move this require
statement above with the others?
I don't think the deleted countries counts as a breaking change. |
I clicked the wrong button. Let me know when you make changes and I'll review again. |
Sorry, I was away. Let me know if anything else needs to be done. |
Welcome back! There's a couple of failing tests due to the library change and country names not being available anymore. I should have it fixed today, then I'll merge it. |
You would fix it or I should fix it? I'm not 100% sure what needs to be done, but I suppose just to remove the countries that are not present anymore from the tests, right? |
I took care of it. Once CI passes, I'll get it merged. |
For future reference, there was an issue where ESBuild was treating the required en.json file as JavaScript instead of JSON. The error I saw was this: plotly.js/tasks/compress_attributes.js Lines 38 to 56 in bddbb14
I'm not sure why this happened because ESBuild can handle JSON files, but it was necessary to stringify the JSON to get ESBuild to recognize the file as JSON. An alternative that worked was to wrap the text in On another note, the library that this PR replaces uses RegEx patterns to match country names which is pretty flexible (though a bit out of date). The new library looks for an exact match of lowercased strings. As such, some previous country names no longer find a match. For example, a ___location of Burma no longer returns the country code for Myanmar and a ___location of Moldova no longer matches because it needs to be "Moldova, Republic of". There are some open PRs to add alternative names (like just "Moldova"), but those haven't been getting approved very quickly. Once they do, we can update the library and make the country lookup a bit better. |
Resolves the issue discussed in #7026.
This implementation does not use regular expressions as before and does not contain countries that do not exist anymore, compared to the previous solution with
country-regex
. But on the other handi18n-iso-countries
seems to be updated frequently, so it will contain updated information on country codes.