diff --git a/cadasta/config/settings/languages.py b/cadasta/config/settings/languages.py index b40ccf292..f00392ad6 100644 --- a/cadasta/config/settings/languages.py +++ b/cadasta/config/settings/languages.py @@ -2,77 +2,78 @@ FORM_LANGS = { - 'af': _('Afrikaans'), - 'ar': _('Arabic'), - 'az': _('Azerbaijani'), - 'be': _('Belarusian'), - 'bg': _('Bulgarian'), - 'bn': _('Bengali'), - 'br': _('Breton'), - 'bs': _('Bosnian'), - 'ca': _('Catalan'), - 'cs': _('Czech'), - 'cy': _('Welsh'), - 'da': _('Danish'), - 'de': _('German'), - 'el': _('Greek'), - 'en': _('English'), - 'eo': _('Esperanto'), - 'es': _('Spanish'), - 'et': _('Estonian'), - 'eu': _('Basque'), - 'fa': _('Persian (Farsi)'), - 'fi': _('Finnish'), - 'fr': _('French'), - 'fy': _('Western Frisian'), - 'ga': _('Irish'), - 'gd': _('Scottish Gaelic'), - 'gl': _('Galician'), - 'he': _('Hebrew'), - 'hi': _('Hindi'), - 'hr': _('Croatian'), - 'hu': _('Hungarian'), - 'ia': _('Interlingua'), - 'id': _('Indonesian'), - 'io': _('Ido'), - 'is': _('Icelandic'), - 'it': _('Italian'), - 'ja': _('Japanese'), - 'ka': _('Georgian'), - 'kk': _('Kazakh'), - 'km': _('Khmer'), - 'kn': _('Kannada'), - 'ko': _('Korean'), - 'lb': _('Luxembourgish'), - 'lt': _('Lithuanian'), - 'lv': _('Latvian'), - 'mk': _('Macedonian'), - 'ml': _('Malayalam'), - 'mn': _('Mongolian'), - 'mr': _('Marathi'), - 'my': _('Burmese'), - 'nb': _('Norwegian (Bokmål)'), - 'ne': _('Nepali'), - 'nl': _('Dutch'), - 'nn': _('Norwegian (Nynorsk)'), - 'os': _('Ossetian'), - 'pa': _('Eastern Punjabi'), - 'pl': _('Polish'), - 'pt': _('Portuguese'), - 'ro': _('Romanian'), - 'ru': _('Russian'), - 'sk': _('Slovak'), - 'sl': _('Slovene'), - 'sq': _('Albanian'), - 'sr': _('Serbian'), - 'sv': _('Swedish'), - 'sw': _('Swahili'), - 'ta': _('Tamil'), - 'te': _('Telugu'), - 'th': _('Thai'), - 'tr': _('Turkish'), - 'tt': _('Tatar'), - 'uk': _('Ukrainian'), - 'ur': _('Urdu'), - 'vi': _('Vietnamese') + 'af': _("Afrikaans"), + 'ar': _("Arabic"), + 'az': _("Azerbaijani"), + 'be': _("Belarusian"), + 'bg': _("Bulgarian"), + 'bn': _("Bengali"), + 'br': _("Breton"), + 'bs': _("Bosnian"), + 'ca': _("Catalan"), + 'cs': _("Czech"), + 'cy': _("Welsh"), + 'da': _("Danish"), + 'de': _("German"), + 'el': _("Greek"), + 'en': _("English"), + 'eo': _("Esperanto"), + 'es': _("Spanish"), + 'et': _("Estonian"), + 'eu': _("Basque"), + 'fa': _("Persian (Farsi)"), + 'fi': _("Finnish"), + 'fr': _("French"), + 'fy': _("Western Frisian"), + 'ga': _("Irish"), + 'gd': _("Scottish Gaelic"), + 'gl': _("Galician"), + 'he': _("Hebrew"), + 'hi': _("Hindi"), + 'hr': _("Croatian"), + 'hu': _("Hungarian"), + 'ia': _("Interlingua"), + 'id': _("Indonesian"), + 'io': _("Ido"), + 'is': _("Icelandic"), + 'it': _("Italian"), + 'ja': _("Japanese"), + 'ka': _("Georgian"), + 'kk': _("Kazakh"), + 'km': _("Khmer"), + 'kn': _("Kannada"), + 'ko': _("Korean"), + 'lb': _("Luxembourgish"), + 'lt': _("Lithuanian"), + 'lv': _("Latvian"), + 'mk': _("Macedonian"), + 'ml': _("Malayalam"), + 'mn': _("Mongolian"), + 'mr': _("Marathi"), + 'my': _("Burmese"), + 'nb': _("Norwegian (Bokmål)"), + 'ne': _("Nepali"), + 'nl': _("Dutch"), + 'nn': _("Norwegian (Nynorsk)"), + 'os': _("Ossetian"), + 'pa': _("Eastern Punjabi"), + 'pl': _("Polish"), + 'pt': _("Portuguese"), + 'ro': _("Romanian"), + 'ru': _("Russian"), + 'sk': _("Slovak"), + 'sl': _("Slovene"), + 'sq': _("Albanian"), + 'sr': _("Serbian"), + 'sv': _("Swedish"), + 'sw': _("Swahili"), + 'ta': _("Tamil"), + 'te': _("Telugu"), + 'th': _("Thai"), + 'tr': _("Turkish"), + 'tt': _("Tatar"), + 'uk': _("Ukrainian"), + 'ur': _("Urdu"), + 'vi': _("Vietnamese"), + 'kar': _("S'gaw Karen") } diff --git a/cadasta/questionnaires/managers.py b/cadasta/questionnaires/managers.py index fcb05a3a5..bccaa8ba9 100644 --- a/cadasta/questionnaires/managers.py +++ b/cadasta/questionnaires/managers.py @@ -6,7 +6,6 @@ from django.contrib.contenttypes.models import ContentType from django.db import models, transaction from django.utils.translation import ugettext as _ -from django.utils.translation import get_language_info from jsonattrs.models import Attribute, AttributeType, Schema from pyxform.builder import create_survey_element_from_dict from pyxform.errors import PyXFormError @@ -130,15 +129,8 @@ def create_attrs_schema(project=None, dict=None, content_type=None, ) -# Python's builtin check_for_language does weird transformations of -# locale names... - def check_for_language(lang): - try: - get_language_info(lang) - return True - except: - return False + return lang in settings.FORM_LANGS.keys() def multilingual_label_check(children): @@ -167,7 +159,7 @@ def fix_languages(node): if (isinstance(node, Element) and node.tagName == 'translation' and node.hasAttribute('lang')): iso_lang = node.getAttribute('lang') - local_lang = get_language_info(iso_lang)['name_local'] + local_lang = settings.FORM_LANGS.get(iso_lang) node.setAttribute('lang', local_lang) else: for child in node.childNodes: