Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dimitrov570 wants to merge9 commits intoplotly:master
base:master
Choose a base branch
Loading
fromdimitrov570:replace-country-regex

Conversation

@dimitrov570
Copy link

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 withcountry-regex. But on the other handi18n-iso-countries seems to be updated frequently, so it will contain updated information on country codes.

@gvwilsongvwilson added communitycommunity contribution P1needed for current cycle fixfixes something broken labelsFeb 18, 2025
@gvwilson
Copy link
Contributor

thanks@dimitrov570 - I'll see if we can get this into the 3.1 release.

camdecoster
camdecoster previously approved these changesJul 30, 2025
Copy link
Contributor

@camdecostercamdecoster left a 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.

CodeCountry
ANTNetherlands Antilles
CSKCzechoslovakia
DDRGerman Democratic Republic
EAZZanzibar
YMDSouth Yemen
YUGYugoslavia

@@ -0,0 +1 @@
- Replace country-regex with i18n-iso-countries[[#7366](https://github.com/plotly/plotly.js/pull/7366)] No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
- Replace country-regex with i18n-iso-countries[[#7366](https://github.com/plotly/plotly.js/pull/7366)]
- Replace country-regexpackagewith i18n-iso-countries[[#7366](https://github.com/plotly/plotly.js/pull/7366)]


// make list of all country iso3 ids from at runtime
varcountryIds=Object.keys(countryRegex);
constcountries=require("i18n-iso-countries");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Could you please move thisrequire statement above with the others?

@gvwilson
Copy link
Contributor

I don't think the deleted countries counts as a breaking change.

camdecoster reacted with thumbs up emoji

@camdecostercamdecoster self-requested a reviewJuly 30, 2025 20:00
@camdecoster
Copy link
Contributor

I clicked the wrong button. Let me know when you make changes and I'll review again.

@dimitrov570
Copy link
Author

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.

@camdecoster
Copy link
Contributor

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.

@dimitrov570
Copy link
Author

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?

@camdecoster
Copy link
Contributor

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.

dimitrov570 reacted with thumbs up emoji

@camdecoster
Copy link
Contributor

For future reference, there was an issue where ESBuild was treating the requireden.json file as JavaScript instead of JSON. The error I saw was this:Expected ";" but found ":". This was due to our use of an ESBuild pluginbrowserifyAdapter, where we passed a custom transform function:

module.exports=function(){
varallChunks=[];
returnthrough(function(chunk,enc,next){
allChunks.push(chunk);
next();
},function(done){
varstr=Buffer.concat(allChunks).toString('utf-8');
this.push(
str
.replace(makeStringRegex('description'),'')
.replace(makeJoinedArrayRegex('description'),'')
.replace(makeArrayRegex('requiredOpts'),'')
.replace(makeArrayRegex('otherOpts'),'')
.replace(makeStringRegex('role'),'')
.replace(makeStringRegex('hrName'),'')
);
done();
});
};

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 inmodule.exports = { <JSON text> }, which is what ESBuild ultimately does during the build process.

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.

@emilykl
Copy link
Contributor

@camdecoster For the country names that have changed, this will be a breaking change for charts showing those countries and usinglocationmode: 'country names', right? Should we hard-code previously-accepted names so that existing charts don't break?

Ultimately seems like we might want to eventually phase outlocationmode: 'country names' entirely because of problems like this.

@marthacryanmarthacryan removed their request for reviewAugust 6, 2025 20:39
@camdecostercamdecoster dismissed theirstale reviewAugust 6, 2025 21:07

I clicked the wrong button.

@camdecoster
Copy link
Contributor

Since this could be a breaking change, we're going to hold off until v4. I added a breaking change warning in 3.1.0.@gvwilson what's the best way to track this so we don't forget it?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@camdecostercamdecosterAwaiting requested review from camdecoster

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

communitycommunity contributionfixfixes something brokenP1needed for current cycle

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@dimitrov570@gvwilson@camdecoster@emilykl

[8]ページ先頭

©2009-2025 Movatter.jp