How to use the langcodes.names.code_to_names function in langcodes

To help you get started, we’ve selected a few langcodes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LuminosoInsight / langcodes / langcodes / __init__.py View on Github external
def _get_name(self, attribute: str, language, min_score: int):
        assert attribute in self.ATTRIBUTES
        if isinstance(language, Language):
            language = language.to_tag()

        attr_value = getattr(self, attribute)
        if attr_value is None:
            return None
        names = code_to_names(attribute, attr_value)
        names['und'] = getattr(self, attribute)
        return self._best_name(names, language, min_score)
github LuminosoInsight / langcodes / langcodes / __init__.py View on Github external
def variant_names(self, language=DEFAULT_LANGUAGE, min_score: int=75) -> list:
        """
        Describe each of the variant parts of the language tag in a natural
        language.
        """
        names = []
        for variant in self.variants:
            var_names = code_to_names('variant', variant)
            names.append(self._best_name(var_names, language, min_score))
        return names