So "cosmopolitan" has been used as a pejorative to denigrate those who are seen as elites gallivanting from country to country as suits their interests, without any attachment to any particular one, by all kinds of groups, over centuries. Wow, must never use the term again!

And people resent elites who look down on them? How dare they? There's a reason those elites are called "their betters", and they should respect them!

Well "nativist" was invented rather recently as a pejorative term for those who do feel attachment to a particular country, and that a country belongs first and foremost to those who were born there and are attached to it, who are free to invoie others to join them,...or not.

Nationalism arose as a result of democracy and the notion of the sovereignty of the people, against a cosmopolitan aristocracy that owned the land and felt free to do with it as they wanted, the people having to adapt to whatever ruler they were now under.