1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-27 00:25:05 +02:00

Update login locale detection to suggest different actions depending on whether multi-language support is installed, per processwire/processwire-issues#184

This commit is contained in:
Ryan Cramer
2017-03-07 08:24:04 -05:00
parent c7d4e5f662
commit 4d6ce48252

View File

@@ -338,12 +338,26 @@ class ProcessLogin extends Process {
// warning about servers with locales that break UTF-8 strings called by basename // warning about servers with locales that break UTF-8 strings called by basename
// and other file functions, due to a long running PHP bug // and other file functions, due to a long running PHP bug
if(basename("§") === "") { if(basename("§") === "") {
$s = stripos(PHP_OS, 'WIN') === 0 ? 'en-US' : 'en_US.UTF-8'; $example = stripos(PHP_OS, 'WIN') === 0 ? 'en-US' : 'en_US.UTF-8';
$this->warning( $msg = $this->_('Warning: your server locale is undefined and may cause issues.') . ' ';
$this->_('Warning: your server locale is undefined and may cause issues.') . ' ' . if($this->wire('modules')->isInstalled('LanguageSupport')) {
sprintf($this->_('Please add this to /site/config.php file (adjust “%s” as needed):'), $s) . ' ' . $msg .= sprintf($this->_('Please translate the “C” locale setting for each language to the proper locale in %s'),
"setlocale(LC_ALL,'$s');" '<u>/wire/modules/LanguageSupport/LanguageSupport.module</u> (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 .= "<br />• <a target='_blank' href='$url'>" . $language->get('title|name') . "</a>";
}
$msg .= "<br /><small>" .
sprintf($this->_('For example, the locale setting for US English might be: %s'), "<strong>$example</strong>") .
"</small>";
$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);
}
} }
} }