def get_lang_choices(newsletters=None): """ Return a localized list of choices for language. List looks like: [[lang_code, lang_name], [lang_code, lang_name], ...] :param newsletters: Either a comma separated string or a list of newsletter ids. """ lang_choices = [] languages = utils.get_languages_for_newsletters(newsletters) for lang in languages: if lang in product_details.languages: lang_name = product_details.languages[lang]['native'] else: try: locale = [ loc for loc in product_details.languages.keys() if loc.startswith(lang) ][0] except IndexError: continue lang_name = product_details.languages[locale]['native'] lang_choices.append([lang, strip_parenthetical(lang_name)]) return sorted(lang_choices, key=itemgetter(1))
def get_lang_choices(newsletters=None): """ Return a localized list of choices for language. List looks like: [[lang_code, lang_name], [lang_code, lang_name], ...] :param newsletters: Either a comma separated string or a list of newsletter ids. """ lang_choices = [] languages = utils.get_languages_for_newsletters(newsletters) for lang in languages: if lang in product_details.languages: lang_name = product_details.languages[lang]['native'] else: try: locale = [loc for loc in product_details.languages.keys() if loc.startswith(lang)][0] except IndexError: continue lang_name = product_details.languages[locale]['native'] lang_choices.append([lang, strip_parenthetical(lang_name)]) return sorted(lang_choices, key=itemgetter(1))