Well, as some people have said, there isn't exactly any standard way to do this. The only way to fill in the States and countries picklists is to do it with its point&click UI.
Nonetheless, there are ways to automate this, one is through Selenium, which I myself have done. The first time it's a bit of a hassle since you have to prepare the scripts, but once you have done so, you can reuse them for all your future projects.
Having said this, I have a few countries done myself in a bitbucket repo here, some of the most used ones at least. Feel free to reuse my scripts if you want. It's as easy as setting your browser in the "Country View" and running the specific script for that country. It's not a full automation, but it's good enough since you can do other tasks while Selenium is running in the background.
In a nutshell, I would recomend you to:
- Install Selenium in your firefox browser
- Login in your Development environment sandbox to try this, since the first go might go wrong and it's a nuisance to modify the states afterwards.
- Go to
Setup > State and Country/Territory Picklists > Configure States and Countries and Territories
and click Edit
on the country you want to fill.
- Open Selenium, insert the script concerning the chosen country and run it.
- Rinse and repeat!
Once you think you have the hang of it after doing it a couple of times in the sandbox environment, go and do it in Production (this can't be deployed). I encourage you to first try a couple of countries in sandbox because it's a very laborious task to modify the states if you get it wrong.
I forgot to mention, in the repository, in the documentation folder you will also find an excel sheet with the formulas to create the scripts for further countries you need. Simply copy/paste a list with the state codes and countries in the columns and on the right the script is generated. As everyone stated, it's laborious, but this makes it easier and faster :)
Hope to have helped!