Honor user's browser language (#558)
Previously we would attempt to satisfy the user's first language preference, immediately falling back to english if that was not possible. Now, we will get the best match of the user's preferred languages. This requires storing the available locales on app startup, so we have mg_globals.available_locales ready to compare them against the list of preferred user languages. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
@@ -19,6 +19,7 @@ from beaker.util import parse_cache_config_options
|
||||
import jinja2
|
||||
|
||||
from mediagoblin.tools import staticdirect
|
||||
from mediagoblin.tools.translate import get_available_locales
|
||||
from mediagoblin.init.config import (
|
||||
read_mediagoblin_config, generate_validation_report)
|
||||
from mediagoblin import mg_globals
|
||||
@@ -37,6 +38,11 @@ class ImproperlyConfigured(Error):
|
||||
pass
|
||||
|
||||
|
||||
def setup_locales():
|
||||
"""Checks which language translations are available and sets them"""
|
||||
setup_globals(available_locales=get_available_locales())
|
||||
|
||||
|
||||
def setup_global_and_app_config(config_path):
|
||||
global_config, validation_result = read_mediagoblin_config(config_path)
|
||||
app_config = global_config['mediagoblin']
|
||||
|
||||
Reference in New Issue
Block a user