X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/6e89310a9285f1ad15d8002bf68f578eada367a0..23369ce9704d3815faae22697338916a60ddf682:/src/nominatim_api/localization.py diff --git a/src/nominatim_api/localization.py b/src/nominatim_api/localization.py index 5964bbee..bbf9225b 100644 --- a/src/nominatim_api/localization.py +++ b/src/nominatim_api/localization.py @@ -11,6 +11,7 @@ from typing import Mapping, List, Optional import re + class Locales: """ Helper class for localization of names. @@ -28,24 +29,20 @@ class Locales: self._add_lang_tags('official_name', 'short_name') self._add_tags('official_name', 'short_name', 'ref') - def __bool__(self) -> bool: return len(self.languages) > 0 - def _add_tags(self, *tags: str) -> None: for tag in tags: self.name_tags.append(tag) self.name_tags.append(f"_place_{tag}") - def _add_lang_tags(self, *tags: str) -> None: for tag in tags: for lang in self.languages: self.name_tags.append(f"{tag}:{lang}") self.name_tags.append(f"_place_{tag}:{lang}") - def display_name(self, names: Optional[Mapping[str, str]]) -> str: """ Return the best matching name from a dictionary of names containing different name variants. @@ -64,7 +61,6 @@ class Locales: # Nothing? Return any of the other names as a default. return next(iter(names.values())) - @staticmethod def from_accept_languages(langstr: str) -> 'Locales': """ Create a localization object from a language list in the