Make document language choices a configurable list. Issue #137.

To override the default list of 600+ languages add a configuration entry to your settings/local.py like so:
DOCUMENTS_LANGUAGE_CHOICES = [('eng', 'English'), ('deu', 'German')]

to make the list translatable import ugettext_lazy and enclose the language name with _():

from django.utils.translation import ugettext_lazy as _
DOCUMENTS_LANGUAGE_CHOICES = [('eng', _('English')), ('deu', _('German'))]
This commit is contained in:
Roberto Rosario
2015-01-14 02:22:47 -04:00
parent adcf621ee1
commit fd1f5d1dad
4 changed files with 7 additions and 8 deletions
+4
View File
@@ -1,12 +1,15 @@
"""Configuration options for the documents app"""
import os
import pycountry
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from smart_settings.api import register_settings
LANGUAGE_CHOICES = [(i.bibliographic, i.name) for i in list(pycountry.languages)]
register_settings(
namespace=u'documents',
module=u'documents.settings',
@@ -27,5 +30,6 @@ register_settings(
#
{'name': u'CACHE_PATH', 'global_name': u'DOCUMENTS_CACHE_PATH', 'default': os.path.join(settings.MEDIA_ROOT, 'image_cache'), 'exists': True},
{'name': u'LANGUAGE', 'global_name': u'DOCUMENTS_LANGUAGE', 'default': u'eng', 'description': _('Default documents language (in ISO639-2 format).')},
{'name': u'LANGUAGE_CHOICES', 'global_name': u'DOCUMENTS_LANGUAGE_CHOICES', 'default': LANGUAGE_CHOICES, 'description': _('List of supported document languages.')},
]
)