From 4d6ce48252eacf5ce755f38bfcb00ca16ba5dc36 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Tue, 7 Mar 2017 08:24:04 -0500 Subject: [PATCH] Update login locale detection to suggest different actions depending on whether multi-language support is installed, per processwire/processwire-issues#184 --- .../Process/ProcessLogin/ProcessLogin.module | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/wire/modules/Process/ProcessLogin/ProcessLogin.module b/wire/modules/Process/ProcessLogin/ProcessLogin.module index d6dae0ac..a8c07203 100644 --- a/wire/modules/Process/ProcessLogin/ProcessLogin.module +++ b/wire/modules/Process/ProcessLogin/ProcessLogin.module @@ -337,13 +337,27 @@ class ProcessLogin extends Process { // warning about servers with locales that break UTF-8 strings called by basename // and other file functions, due to a long running PHP bug - if(basename("§") === "") { - $s = stripos(PHP_OS, 'WIN') === 0 ? 'en-US' : 'en_US.UTF-8'; - $this->warning( - $this->_('Warning: your server locale is undefined and may cause issues.') . ' ' . - sprintf($this->_('Please add this to /site/config.php file (adjust “%s” as needed):'), $s) . ' ' . - "setlocale(LC_ALL,'$s');" - ); + if(basename("§") === "") { + $example = stripos(PHP_OS, 'WIN') === 0 ? 'en-US' : 'en_US.UTF-8'; + $msg = $this->_('Warning: your server locale is undefined and may cause issues.') . ' '; + if($this->wire('modules')->isInstalled('LanguageSupport')) { + $msg .= sprintf($this->_('Please translate the “C” locale setting for each language to the proper locale in %s'), + '/wire/modules/LanguageSupport/LanguageSupport.module (shortcuts provided below):'); + foreach($this->wire('languages') as $language) { + $url = $this->wire('config')->urls->admin . "setup/language-translator/edit/?language_id=$language->id&" . + "textdomain=wire--modules--languagesupport--languagesupport-module&" . + "filename=wire/modules/LanguageSupport/LanguageSupport.module"; + $msg .= "
" . $language->get('title|name') . ""; + } + $msg .= "
" . + sprintf($this->_('For example, the locale setting for US English might be: %s'), "$example") . + ""; + $this->warning($msg, Notice::allowMarkup); + } else { + $msg .= sprintf($this->_('Please add this to /site/config.php file (adjust “%s” as needed):'), $example) . ' ' . + "setlocale(LC_ALL,'$example');"; + $this->warning($msg); + } } }