self.variant = variant
#: the modifier
self.modifier = modifier
- self.__data = None
+ self.__data: localedata.LocaleDataDict | None = None
identifier = str(self)
identifier_without_modifier = identifier.partition('@')[0]
aliases=aliases)
if identifier:
return Locale.parse(identifier, sep=sep)
+ return None
@classmethod
def parse(
details.append(locale.variants.get(self.variant))
if self.modifier:
details.append(self.modifier)
- details = filter(None, details)
- if details:
- retval += f" ({', '.join(details)})"
+ detail_string = ', '.join(atom for atom in details if atom)
+ if detail_string:
+ retval += f" ({detail_string})"
return retval
display_name = property(get_display_name, doc="""\
return get_locale_identifier(parse_locale(locale))
except ValueError:
pass
+ return None
def negotiate_locale(preferred: Iterable[str], available: Iterable[str], sep: str = '_', aliases: Mapping[str, str] = LOCALE_ALIASES) -> str | None: