def english_name(self): name = langtable.language_name(languageId=self.language, territoryId=self.territory, scriptId=self.script, languageIdQuery="en") # some languages don't start with a capital letter return name.title()
def get_native_name(locale): """Function returning native name for the given locale. :param locale: locale to return native name for :type locale: str :return: english name for the locale or empty string if unknown :rtype: st :raise InvalidLocaleSpec: if an invalid locale is given (see is_valid_langcode) """ raise_on_invalid_locale(locale) return langtable.language_name(languageId=locale)
def get_english_name(locale): """Function returning english name for the given locale. :param locale: locale to return english name for :type locale: str :return: english name for the locale or empty string if unknown :rtype: st :raise InvalidLocaleSpec: if an invalid locale is given (see is_valid_langcode) """ raise_on_invalid_locale(locale) name = langtable.language_name(languageId=locale, languageIdQuery="en") return upcase_first_letter(name)
def get_english_name(locale): """ Function returning english name for the given locale. :param locale: locale to return english name for :type locale: str :return: english name for the locale or empty string if unknown :rtype: st :raise InvalidLocaleSpec: if an invalid locale is given (see LANGCODE_RE) """ parts = parse_langcode(locale) if "language" not in parts: raise InvalidLocaleSpec("'%s' is not a valid locale" % locale) name = langtable.language_name(languageId=parts["language"], territoryId=parts.get("territory", ""), scriptId=parts.get("script", ""), languageIdQuery="en") return upcase_first_letter(name)
def get_unique_language_names(alllanglist): uniq_lang_list = [] dup = 0 processed = 0 for item in alllanglist: if item.count('_') or len(item) < 4: processed = processed + 1 langname = langtable.language_name( languageId=item, languageIdQuery="en").encode("UTF-8") if len(langname) < 1: uniq_lang_list.append(langname) if langname not in uniq_lang_list: uniq_lang_list.append(langname) else: dup = dup + 1 else: if item not in uniq_lang_list: uniq_lang_list.append(item) else: dup = dup + 1 return sorted(uniq_lang_list)
def lc_to_langname(lc): return langtable.language_name(languageId=lc, languageIdQuery="en").encode("UTF-8")
def display_name(self): name = langtable.language_name(languageId=self.language, territoryId=self.territory, scriptId=self.script) # some languages don't start with a capital letter return name.title()
if match: tag = match.group('tag') value = match.group('value') if tag == 'language': language = value if tag == 'lang_name': lang_name = value if tag == 'territory': territory = value if tag == 'country_name': country_name = value lang_name = replace_glib_codepoints_with_characters(lang_name) language = replace_glib_codepoints_with_characters(language) territory = replace_glib_codepoints_with_characters(territory) country_name = replace_glib_codepoints_with_characters(country_name) langtable_language_english = langtable.language_name( languageId=locale_id, languageIdQuery='en') langtable_language_endonym = langtable.language_name( languageId=locale_id) langtable_territory_english = langtable.territory_name( territoryId=territory_id, languageIdQuery='en') langtable_territory_endonym = langtable.territory_name( territoryId=territory_id, languageIdQuery=locale_id) langtable_language_english = langtable_language_english.replace( ' (' + langtable_territory_english + ')', '').replace(' (Devanagari script)', '').replace(' (Latin)', '') langtable_language_endonym = langtable_language_endonym.replace( ' (' + langtable_territory_endonym + ')', '') if langtable_language_endonym != lang_name: print('locale_id %s' % locale_id) print(' glibc : lang_name=%s' % lang_name) print(' langtable: lang_name=%s' % langtable_language_endonym)
def langcode_to_langname(cls, langcode): """ We need to get the language name for the given locale code """ return langtable.language_name(languageId=langcode, languageIdQuery="en")