diff --git a/scripts/geodata/address_formatting/formatter.py b/scripts/geodata/address_formatting/formatter.py index 89981424..be54d0c7 100644 --- a/scripts/geodata/address_formatting/formatter.py +++ b/scripts/geodata/address_formatting/formatter.py @@ -562,7 +562,16 @@ class AddressFormatter(object): if not template: return None - country = self.country_aliases.get(country.upper(), country).lower() + country_language = None + if language: + country_language = '{}_{}'.format(country, language) + + alias_country = self.country_aliases.get(country.upper(), country).lower() + for term in (country, country_language): + if term in self.country_insertions or term in self.country_conditionals: + break + else: + country = alias_country cache_keys = [] @@ -571,9 +580,6 @@ class AddressFormatter(object): insertions = nested_get(self.country_insertions, (country, component), default=None) conditionals = nested_get(self.country_conditionals, (country, component), default=None) - if language: - country_language = '{}_{}'.format(country, language) - if insertions is None and language: insertions = nested_get(self.country_insertions, (country_language, component), default=None) scope = country_language