diff --git a/resources/library_customizations.php b/resources/library_customizations.php index 9f394bb4..f1770b6e 100644 --- a/resources/library_customizations.php +++ b/resources/library_customizations.php @@ -176,6 +176,16 @@ function get_subdivision_customizations($parentId) { 'postal_code_pattern' => '24[46-9]|254|26[23]', ], ]; + // Remove Swiss administrative areas, they're not used for addressing. + // https://github.com/googlei18n/libaddressinput/issues/89 + $subdivisionCustomizations['CH'] = [ + '_remove' => [ + 'CH-AG', 'CH-AR', 'CH-AI', 'CH-BE', 'CH-BL', 'CH-BS', 'CH-FR', + 'CH-GE', 'CH-GL', 'CH-GR', 'CH-JU', 'CH-LU', 'CH-NE', 'CH-NW', + 'CH-OW', 'CH-SH', 'CH-SZ', 'CH-SO', 'CH-SG', 'CH-TI', 'CH-TG', + 'CH-UR', 'CH-VD', 'CH-VS', 'CH-ZG', 'CH-ZH', + ], + ]; return isset($subdivisionCustomizations[$parentId]) ? $subdivisionCustomizations[$parentId] : []; } diff --git a/resources/subdivision/CH.json b/resources/subdivision/CH.json deleted file mode 100644 index d04ec048..00000000 --- a/resources/subdivision/CH.json +++ /dev/null @@ -1,319 +0,0 @@ -{ - "country_code": "CH", - "parent_id": null, - "locale": "de", - "subdivisions": { - "CH-AG": { - "code": "AG", - "name": "Aargau", - "translations": { - "fr": { - "name": "Argovie" - }, - "it": { - "name": "Argovia" - } - } - }, - "CH-AR": { - "code": "AR", - "name": "Appenzell Ausserrhoden", - "translations": { - "fr": { - "name": "Appenzell Rhodes-Extérieures" - }, - "it": { - "name": "Appenzello Esterno" - } - } - }, - "CH-AI": { - "code": "AI", - "name": "Appenzell Innerrhoden", - "translations": { - "fr": { - "name": "Appenzell Rhodes-Intérieures" - }, - "it": { - "name": "Appenzello Interno" - } - } - }, - "CH-BL": { - "code": "BL", - "name": "Basel-Landschaft", - "translations": { - "fr": { - "name": "Bâle-Campagne" - }, - "it": { - "name": "Basilea Campagna" - } - } - }, - "CH-BS": { - "code": "BS", - "name": "Basel-Stadt", - "translations": { - "fr": { - "name": "Bâle-Ville" - }, - "it": { - "name": "Basilea Città" - } - } - }, - "CH-BE": { - "code": "BE", - "name": "Bern", - "translations": { - "fr": { - "name": "Berne" - }, - "it": { - "name": "Berna" - } - } - }, - "CH-FR": { - "code": "FR", - "name": "Freiburg", - "translations": { - "fr": { - "name": "Fribourg" - }, - "it": { - "name": "Friburgo" - } - } - }, - "CH-GE": { - "code": "GE", - "name": "Genf", - "translations": { - "fr": { - "name": "Genève" - }, - "it": { - "name": "Ginevra" - } - } - }, - "CH-GL": { - "code": "GL", - "name": "Glarus", - "translations": { - "fr": { - "name": "Glaris" - }, - "it": { - "name": "Glarona" - } - } - }, - "CH-GR": { - "code": "GR", - "name": "Graubünden", - "translations": { - "fr": { - "name": "Grisons" - }, - "it": { - "name": "Grigioni" - } - } - }, - "CH-JU": { - "code": "JU", - "name": "Jura", - "translations": { - "fr": { - "name": "Jura" - }, - "it": { - "name": "Giura" - } - } - }, - "CH-LU": { - "code": "LU", - "name": "Luzern", - "translations": { - "fr": { - "name": "Lucerne" - }, - "it": { - "name": "Lucerna" - } - } - }, - "CH-NE": { - "code": "NE", - "name": "Neuenburg", - "translations": { - "fr": { - "name": "Neuchâtel" - }, - "it": { - "name": "Neuchâtel" - } - } - }, - "CH-NW": { - "code": "NW", - "name": "Nidwalden", - "translations": { - "fr": { - "name": "Nidwald" - }, - "it": { - "name": "Nidvaldo" - } - } - }, - "CH-OW": { - "code": "OW", - "name": "Obwalden", - "translations": { - "fr": { - "name": "Obwald" - }, - "it": { - "name": "Obvaldo" - } - } - }, - "CH-SH": { - "code": "SH", - "name": "Schaffhausen", - "translations": { - "fr": { - "name": "Schaffhouse" - }, - "it": { - "name": "Sciaffusa" - } - } - }, - "CH-SZ": { - "code": "SZ", - "name": "Schwyz", - "translations": { - "fr": { - "name": "Schwyz" - }, - "it": { - "name": "Svitto" - } - } - }, - "CH-SO": { - "code": "SO", - "name": "Solothurn", - "translations": { - "fr": { - "name": "Soleure" - }, - "it": { - "name": "Soletta" - } - } - }, - "CH-SG": { - "code": "SG", - "name": "St. Gallen", - "translations": { - "fr": { - "name": "Saint-Gall" - }, - "it": { - "name": "San Gallo" - } - } - }, - "CH-TI": { - "code": "TI", - "name": "Tessin", - "translations": { - "fr": { - "name": "Tessin" - }, - "it": { - "name": "Ticino" - } - } - }, - "CH-TG": { - "code": "TG", - "name": "Thurgau", - "translations": { - "fr": { - "name": "Thurgovie" - }, - "it": { - "name": "Turgovia" - } - } - }, - "CH-UR": { - "code": "UR", - "name": "Uri", - "translations": { - "fr": { - "name": "Uri" - }, - "it": { - "name": "Uri" - } - } - }, - "CH-VD": { - "code": "VD", - "name": "Waadt", - "translations": { - "fr": { - "name": "Vaud" - }, - "it": { - "name": "Vaud" - } - } - }, - "CH-VS": { - "code": "VS", - "name": "Wallis", - "translations": { - "fr": { - "name": "Valais" - }, - "it": { - "name": "Vallese" - } - } - }, - "CH-ZG": { - "code": "ZG", - "name": "Zug", - "translations": { - "fr": { - "name": "Zoug" - }, - "it": { - "name": "Zugo" - } - } - }, - "CH-ZH": { - "code": "ZH", - "name": "Zürich", - "translations": { - "fr": { - "name": "Zurich" - }, - "it": { - "name": "Zurigo" - } - } - } - } -} \ No newline at end of file diff --git a/resources/subdivision/depths.json b/resources/subdivision/depths.json index df4e0feb..24ccfd71 100644 --- a/resources/subdivision/depths.json +++ b/resources/subdivision/depths.json @@ -31,7 +31,6 @@ "ES": 1, "KN": 1, "SR": 1, - "CH": 1, "TW": 2, "TH": 1, "TR": 1, diff --git a/scripts/generate.php b/scripts/generate.php index 95e9286c..4e076b47 100644 --- a/scripts/generate.php +++ b/scripts/generate.php @@ -239,6 +239,10 @@ function generate_subdivisions($countryCode, $parentId, $subdivisionPaths, $lang // Apply any found customizations. $customizations = get_subdivision_customizations($parentId); $subdivisions[$parentId] = apply_subdivision_customizations($subdivisions[$parentId], $customizations); + // All subdivisions have been removed. Remove the rest of the data. + if (empty($subdivisions[$parentId]['subdivisions'])) { + unset($subdivisions[$parentId]); + } return $subdivisions; }