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:
@@ -1,5 +1,3 @@
|
||||
import pycountry
|
||||
|
||||
PICTURE_ERROR_SMALL = u'picture_error.png'
|
||||
PICTURE_ERROR_MEDIUM = u'1297211435_error.png'
|
||||
PICTURE_UNKNOWN_SMALL = u'1299549572_unknown2.png'
|
||||
@@ -7,6 +5,4 @@ PICTURE_UNKNOWN_MEDIUM = u'1299549805_unknown.png'
|
||||
|
||||
DEFAULT_ZIP_FILENAME = u'document_bundle.zip'
|
||||
|
||||
LANGUAGE_CHOICES = [(i.bibliographic, i.name) for i in list(pycountry.languages)]
|
||||
|
||||
DOCUMENT_IMAGE_TASK_TIMEOUT = 20
|
||||
|
||||
@@ -32,12 +32,11 @@ from mimetype.api import get_mimetype
|
||||
|
||||
from .events import event_document_create
|
||||
from .exceptions import NewDocumentVersionNotAllowed
|
||||
from .literals import LANGUAGE_CHOICES
|
||||
from .managers import (DocumentManager, DocumentPageTransformationManager,
|
||||
DocumentTypeManager, RecentDocumentManager)
|
||||
from .runtime import storage_backend
|
||||
from .settings import (CACHE_PATH, DISPLAY_SIZE, LANGUAGE, ZOOM_MAX_LEVEL,
|
||||
ZOOM_MIN_LEVEL)
|
||||
from .settings import (CACHE_PATH, DISPLAY_SIZE, LANGUAGE, LANGUAGE_CHOICES,
|
||||
ZOOM_MAX_LEVEL, ZOOM_MIN_LEVEL)
|
||||
from .signals import post_version_upload, post_document_type_change
|
||||
|
||||
HASH_FUNCTION = lambda x: hashlib.sha256(x).hexdigest() # document image cache name hash function
|
||||
|
||||
@@ -2,9 +2,9 @@ from __future__ import absolute_import
|
||||
|
||||
from rest_framework import serializers
|
||||
|
||||
from .literals import LANGUAGE_CHOICES
|
||||
from .models import (Document, DocumentVersion, DocumentPage, DocumentType,
|
||||
RecentDocument)
|
||||
from .settings import LANGUAGE_CHOICES
|
||||
|
||||
|
||||
class DocumentPageSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
@@ -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.')},
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user