How to use the langcodes.db.lazy_property 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 / db.py View on Github external
    @lazy_property
    def language_matching(self):
        """
        Information about the strength of match between certain pairs of
        languages.
        """
        match_json = json.load(
            open(data_filename('cldr/supplemental/languageMatching.json'))
        )
        matches = {}
        match_data = match_json['supplemental']['languageMatching']['written']
        for item in match_data:
            match = item['languageMatch']
            desired = match['_desired']
            supported = match['_supported']
            value = match['_percent']
            if (desired, supported) not in matches:
github LuminosoInsight / langcodes / langcodes / db.py View on Github external
    @lazy_property
    def normalized_macrolanguages(self):
        """
        Codes that the Unicode Consortium would rather replace with macrolanguages.
        """
        return {
            orig.lower(): new
            for (orig, new) in self.language_replacements(macro=True)
        }
github LuminosoInsight / langcodes / langcodes / db.py View on Github external
    @lazy_property
    def normalized_languages(self):
        """
        Non-standard codes that should be unconditionally replaced.
        """
        results = {orig.lower(): new.lower()
                   for (orig, new) in self.language_replacements()}

        # one more to handle the 'root' locale
        results['root'] = 'und'
        return results
github LuminosoInsight / langcodes / langcodes / db.py View on Github external
    @lazy_property
    def macrolanguages(self):
        """
        Mappings for all languages that have macrolanguages.
        """
        return {lang: macro for (lang, macro) in self.list_macrolanguages()}
github LuminosoInsight / langcodes / langcodes / db.py View on Github external
    @lazy_property
    def parent_locales(self):
        """
        CLDR's list of which locales are "parents" of other locales.
        """
        pl_json = json.load(
            open(data_filename('cldr/supplemental/parentLocales.json'), encoding='ascii')
        )
        return pl_json['supplemental']['parentLocales']['parentLocale']
github LuminosoInsight / langcodes / langcodes / db.py View on Github external
    @lazy_property
    def normalized_regions(self):
        """
        Regions that have been renamed, merged, or re-coded. (This package doesn't
        handle the ones that have been split, like Yugoslavia.)
        """
        return {
            orig.upper(): new.upper()
            for (orig, new) in self.region_replacements()
        }
github LuminosoInsight / langcodes / langcodes / db.py View on Github external
    @lazy_property
    def likely_subtags(self):
        """
        Information on which subtag values are most likely given other subtags.
        """
        ls_json = json.load(
            open(data_filename('cldr/supplemental/likelySubtags.json'))
        )
        return ls_json['supplemental']['likelySubtags']
github LuminosoInsight / langcodes / langcodes / db.py View on Github external
    @lazy_property
    def default_scripts(self):
        """
        Most languages imply a particular script that they should be written in.
        This data is used by the `assume_script` and `simplify_script` methods.
        """
        return {
            lang: script
            for (lang, script) in self.list_suppressed_scripts()
        }