Skip to content

Latest commit

 

History

History
93 lines (66 loc) · 2.18 KB

README.md

File metadata and controls

93 lines (66 loc) · 2.18 KB

I18n Country Subdivisions

Overview

Package to support internationalization, specifically the Subdivision (provinces/states/region) defined in ISO 3166-2.

It depends on the neovisionaries i18n (nv-i18n) package for defining all the CountryCodes used.

The author is well aware that there are bound to be problems in the data set. If nothing else, the data changes over time, so please submit issues when something is wrong (preferably with a verifiably link to the correct data).

While the information on what kind of subdivision it is (region, island, state, province, city etc), they are too many different kinds for them to be readily usable and thus they are not available.

License

Apache License, Version 2.0

Download

git clone https://github.com/tobias-/i18n-subdivisions.git

All code is generated by the groovy script src/build/groovy/generateSubdivisions.groovy from the html files in src/build/resources/.

Building

mvn clean install -Pdownload-subdivisions

Releasing

mvn release:prepare release:perform -Pdownload-subdivisions

Example

List all the subdivision codes available for a specific country.

for (CountrySubdivisionCode code : SubdivisionFactory.getSubdivisions(CountryCode.BE)) {
    System.out.format("[%s] %s\n", code, code.getName());
}

Find the region with a specific code and in a specific country. Codes are not unique across countries, ergo country must be specified.

for (CountrySubdivisionCode code : SubdivisionFactory.getSubdivisions(CountryCode.BE)) {
    System.out.format("[%s] %s\n", code, code.getName());
}

Maven

<dependency>
    <groupId>be.olsson</groupId>
    <artifactId>i18n-subdivisions</artifactId>
    <version>0.1</version>
</dependency>

Gradle

dependencies {
    compile 'be.olsson:i18n-subdivisions:0.1'
}

See Also

TODO

  • Verify with another source of the codes
  • If anyone wants them, include subdivision types in the enum