mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
Show Gujarati in the list of UI languages
- Explicitly setup the list of Django languages. Keep them sorted by language code. - Fallback to language name when Django can't provide locale language name. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
201b256fe5
commit
7ee4d13dce
@ -69,14 +69,21 @@ class LanguageSelectionFormMixin:
|
||||
supported_languages = [
|
||||
(None, _('Use the language preference set in the browser'))
|
||||
]
|
||||
|
||||
def _get_local_name(language_code, language_name):
|
||||
try:
|
||||
return get_language_info(language_code)['name_local']
|
||||
except KeyError:
|
||||
return language_name
|
||||
|
||||
for language_code, language_name in settings.LANGUAGES:
|
||||
locale_code = translation.to_locale(language_code)
|
||||
plinth_dir = os.path.dirname(plinth.__file__)
|
||||
if language_code == 'en' or os.path.exists(
|
||||
os.path.join(plinth_dir, 'locale', locale_code)):
|
||||
supported_languages.append(
|
||||
(language_code,
|
||||
get_language_info(language_code)['name_local']))
|
||||
supported_languages.append((language_code,
|
||||
_get_local_name(
|
||||
language_code, language_name)))
|
||||
|
||||
self.fields['language'].choices = supported_languages
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ import stat
|
||||
import django.conf
|
||||
import django.core.management
|
||||
import django.core.wsgi
|
||||
from django.conf import global_settings
|
||||
from django.contrib.messages import constants as message_constants
|
||||
|
||||
from . import cfg, log, module_loader
|
||||
@ -114,6 +115,7 @@ def init():
|
||||
FORCE_SCRIPT_NAME=cfg.server_dir,
|
||||
INSTALLED_APPS=applications,
|
||||
IPWARE_META_PRECEDENCE_ORDER=('HTTP_X_FORWARDED_FOR', ),
|
||||
LANGUAGES=get_languages(),
|
||||
LOGGING=log.get_configuration(),
|
||||
LOGIN_URL='users:login',
|
||||
LOGIN_REDIRECT_URL='index',
|
||||
@ -161,6 +163,21 @@ def init():
|
||||
os.chmod(cfg.store_file, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
|
||||
|
||||
|
||||
def get_languages():
|
||||
"""Return list of languages to show in the interface.
|
||||
|
||||
Add additional languages that FreedomBox support but Django doesn't.
|
||||
|
||||
"""
|
||||
def gettext_noop(string):
|
||||
"""Django's actual translation methods need Django to be setup."""
|
||||
return string
|
||||
|
||||
return sorted(list(global_settings.LANGUAGES) + [
|
||||
('gu', gettext_noop('Gujarati')),
|
||||
])
|
||||
|
||||
|
||||
def get_wsgi_application():
|
||||
"""Return Django wsgi application."""
|
||||
return django.core.wsgi.get_wsgi_application()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user