diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index 4c7c8136f..7fdad5b44 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -238,7 +238,29 @@ form: languages.home_redirect.include_route: type: toggle label: PLUGIN_ADMIN.HOME_REDIRECT_INCLUDE_ROUTE - help: PLUGIN_ADMIN.HOME_REDIRECT_INCLUDE_ROUTE + help: PLUGIN_ADMIN.HOME_REDIRECT_INCLUDE_ROUTE_HELP + highlight: 0 + options: + 1: PLUGIN_ADMIN.YES + 0: PLUGIN_ADMIN.NO + validate: + type: bool + + languages.http_accept_language: + type: toggle + label: PLUGIN_ADMIN.HTTP_ACCEPT_LANGUAGE + help: PLUGIN_ADMIN.HTTP_ACCEPT_LANGUAGE_HELP + highlight: 0 + options: + 1: PLUGIN_ADMIN.YES + 0: PLUGIN_ADMIN.NO + validate: + type: bool + + languages.override_locale: + type: toggle + label: PLUGIN_ADMIN.OVERRIDE_LOCALE + help: PLUGIN_ADMIN.OVERRIDE_LOCALE_HELP highlight: 0 options: 1: PLUGIN_ADMIN.YES diff --git a/system/config/system.yaml b/system/config/system.yaml index 502d930b9..efaddf136 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -1,5 +1,6 @@ absolute_urls: false # Absolute or relative URLs for `base_url` timezone: '' # Valid values: http://php.net/manual/en/timezones.php +default_locale: # Default locale (defaults to system) param_sep: ':' # Parameter separator, use ';' for Apache on windows languages: @@ -10,7 +11,8 @@ languages: home_redirect: include_lang: true # Include language in home redirect (/en) include_route: false # Include route in home redirect (/blog) - + http_accept_language: false # Attempt to set the language based on http_accept_language header in the browser + override_locale: false # Override the default or system locale with language specific one home: alias: '/home' # Default path for home, ie / diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index ba67052ff..2cb5a9437 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -192,6 +192,13 @@ class Grav extends Container date_default_timezone_set($this['config']->get('system.timezone')); } + // Initialize Locale if set and configured + if ($this['language']->enabled() && $this['config']->get('system.languages.override_locale')) { + setlocale(LC_ALL, $this['language']->getLanguage()); + } elseif ($this['config']->get('system.default_locale')) { + setlocale(LC_ALL, $this['config']->get('system.default_locale')); + } + $debugger->startTimer('streams', 'Streams'); $this['streams']; $debugger->stopTimer('streams');