Replace the DOCUMENTS_LANGUAGE_CHOICES setting option. Replaced with the new DOCUMENTS_LANGUAGE_CODES.
Reduce default language code choice from 7800 to the top 100 spoken languages and related (https://en.wikipedia.org/wiki/List_of_languages_by_number_of_native_speakers). Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -169,6 +169,8 @@
|
||||
- Add COMMON_PRODUCTION_ERROR_LOGGING setting to control the logging of errors in production. Defaults to False.
|
||||
- Change the error log file handle class to RotatingFileHandle to avoid an indefinitely growing log file.
|
||||
- Disable embedded signatute verification during the perform upgrade command.
|
||||
- Replace the DOCUMENTS_LANGUAGE_CHOICES setting option. Replaced with the new DOCUMENTS_LANGUAGE_CODES.
|
||||
|
||||
|
||||
2.7.3 (2017-09-11)
|
||||
==================
|
||||
|
||||
@@ -489,6 +489,8 @@ Other changes worth mentioning
|
||||
Removals
|
||||
--------
|
||||
* Data filters app.
|
||||
* DOCUMENTS_LANGUAGE_CHOICES setting option. Replaced with
|
||||
DOCUMENTS_LANGUAGE_CODES.
|
||||
|
||||
Known issues
|
||||
------------
|
||||
|
||||
@@ -17,7 +17,7 @@ from .models import (
|
||||
)
|
||||
from .literals import DEFAULT_ZIP_FILENAME, PAGE_RANGE_ALL, PAGE_RANGE_CHOICES
|
||||
from .permissions import permission_document_create
|
||||
from .settings import setting_language_choices
|
||||
from .runtime import language_choices
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -67,7 +67,7 @@ class DocumentForm(forms.ModelForm):
|
||||
model = Document
|
||||
widgets = {
|
||||
'language': forms.Select(
|
||||
choices=setting_language_choices.value, attrs={
|
||||
choices=language_choices, attrs={
|
||||
'class': 'select2'
|
||||
}
|
||||
)
|
||||
@@ -120,7 +120,7 @@ class DocumentPropertiesForm(DetailForm):
|
||||
{'label': _('UUID'), 'field': 'uuid'},
|
||||
{
|
||||
'label': _('Language'),
|
||||
'field': lambda x: dict(setting_language_choices.value).get(
|
||||
'field': lambda x: dict(language_choices).get(
|
||||
document.language, _('Unknown')
|
||||
)
|
||||
},
|
||||
|
||||
@@ -9,6 +9,23 @@ CHECK_TRASH_PERIOD_INTERVAL = 60
|
||||
DELETE_STALE_STUBS_INTERVAL = 60 * 10 # 10 minutes
|
||||
DEFAULT_DELETE_PERIOD = 30
|
||||
DEFAULT_DELETE_TIME_UNIT = TIME_DELTA_UNIT_DAYS
|
||||
DEFAULT_LANGUAGE = 'eng'
|
||||
DEFAULT_LANGUAGE_CODES = (
|
||||
'ilo', 'run', 'uig', 'hin', 'pan', 'pnb', 'wuu', 'msa', 'kxd', 'ind',
|
||||
'zsm', 'jax', 'meo', 'kvr', 'xmm', 'min', 'mui', 'zmi', 'max', 'mfa',
|
||||
'cjy', 'nan', 'pus', 'pbu', 'pbt', 'wne', 'hsn', 'hak', 'ful', 'fuc',
|
||||
'fuf', 'ffm', 'fue', 'fuh', 'fuq', 'fuv', 'fub', 'fui', 'nep', 'npi',
|
||||
'dty', 'sin', 'khm', 'kxm', 'ell', 'grc', 'cpg', 'gmy', 'pnt', 'tsd',
|
||||
'yej', 'nya', 'mnp', 'dhd', 'cdo', 'hil', 'bcc', 'bgn', 'bgp', 'cmn',
|
||||
'kok', 'spa', 'eng', 'ara', 'por', 'ben', 'rus', 'jpn', 'deu', 'jav',
|
||||
'tel', 'vie', 'kor', 'fra', 'mar', 'tam', 'urd', 'tur', 'ita', 'yue',
|
||||
'tha', 'guj', 'fas', 'pol', 'kan', 'mal', 'sun', 'hau', 'ory', 'mya',
|
||||
'ukr', 'bho', 'tgl', 'yor', 'mai', 'uzb', 'snd', 'amh', 'ron', 'orm',
|
||||
'ibo', 'aze', 'awa', 'gan', 'ceb', 'nld', 'kur', 'hbs', 'mlg', 'skr',
|
||||
'ctg', 'zha', 'tuk', 'asm', 'mad', 'som', 'mwr', 'mag', 'bgc', 'hun',
|
||||
'hne', 'dcc', 'aka', 'kaz', 'syl', 'zul', 'ces', 'kin', 'hat', 'que',
|
||||
'swe', 'hmn', 'sna', 'mos', 'xho', 'bel'
|
||||
)
|
||||
DEFAULT_ZIP_FILENAME = 'document_bundle.zip'
|
||||
DEFAULT_DOCUMENT_TYPE_LABEL = _('Default')
|
||||
DOCUMENT_IMAGE_TASK_TIMEOUT = 20
|
||||
|
||||
16
mayan/apps/documents/runtime.py
Normal file
16
mayan/apps/documents/runtime.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
#import os
|
||||
|
||||
import pycountry
|
||||
|
||||
#from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from .settings import setting_language_codes
|
||||
|
||||
language_choices = [
|
||||
(
|
||||
iso639_3, _(pycountry.languages.get(alpha_3=iso639_3).name)
|
||||
) for iso639_3 in setting_language_codes.value
|
||||
]
|
||||
@@ -2,16 +2,12 @@ from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
import pycountry
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from smart_settings import Namespace
|
||||
|
||||
LANGUAGE_CHOICES = [
|
||||
(i.iso639_3_code, i.name) for i in list(pycountry.languages)
|
||||
]
|
||||
from .literals import DEFAULT_LANGUAGE, DEFAULT_LANGUAGE_CODES
|
||||
|
||||
namespace = Namespace(name='documents', label=_('Documents'))
|
||||
setting_display_width = namespace.add_setting(
|
||||
@@ -93,12 +89,12 @@ setting_documentimagecache_storage_arguments = namespace.add_setting(
|
||||
)
|
||||
)
|
||||
setting_language = namespace.add_setting(
|
||||
global_name='DOCUMENTS_LANGUAGE', default='eng',
|
||||
help_text=_('Default documents language (in ISO639-2 format).')
|
||||
global_name='DOCUMENTS_LANGUAGE', default=DEFAULT_LANGUAGE,
|
||||
help_text=_('Default documents language (in ISO639-3 format).')
|
||||
)
|
||||
setting_language_choices = namespace.add_setting(
|
||||
global_name='DOCUMENTS_LANGUAGE_CHOICES', default=LANGUAGE_CHOICES,
|
||||
help_text=_('List of supported document languages.')
|
||||
setting_language_codes = namespace.add_setting(
|
||||
global_name='DOCUMENTS_LANGUAGE_CODES', default=DEFAULT_LANGUAGE_CODES,
|
||||
help_text=_('List of supported document languages. In ISO639-3 format.')
|
||||
)
|
||||
setting_disable_base_image_cache = namespace.add_setting(
|
||||
global_name='DOCUMENTS_DISABLE_BASE_IMAGE_CACHE', default=False,
|
||||
|
||||
@@ -39,7 +39,7 @@ mock==2.0.0
|
||||
node-semver==0.3.0
|
||||
|
||||
pathlib==1.0.1
|
||||
pycountry==1.20
|
||||
pycountry==18.5.26
|
||||
PyPDF2==1.26.0
|
||||
pyocr==0.5.1
|
||||
python-dateutil==2.6.1
|
||||
|
||||
Reference in New Issue
Block a user