]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Use LC_COLLATE instead of LC_MESSAGES if php-intl is not installed 1070/head
authorArthurHoaro <arthur@hoa.ro>
Wed, 31 Jan 2018 11:39:17 +0000 (12:39 +0100)
committerArthurHoaro <arthur@hoa.ro>
Wed, 31 Jan 2018 11:39:17 +0000 (12:39 +0100)
As stated in the docs:

> LC_MESSAGES for system responses (available if PHP was compiled with libintl)

Fixes #1067

application/Languages.php
index.php

index 357c7524ed458a128148522b124dd17876faac87..3eb3388f48f6a01ac87c872c408018c9c574cdec 100644 (file)
@@ -69,6 +69,8 @@ class Languages
     {
         $this->conf = $conf;
         $confLanguage = $this->conf->get('translation.language', 'auto');
+        // Auto mode or invalid parameter, use the detected language.
+        // If the detected language is invalid, it doesn't matter, it will use English.
         if ($confLanguage === 'auto' || ! $this->isValidLanguage($confLanguage)) {
             $this->language = substr($language, 0, 5);
         } else {
index d57789e656749c248fbffe1e60a862b0aad4fbe6..2de9be0a1824b31dc57fd17d34c7b1f1999afe44 100644 (file)
--- a/index.php
+++ b/index.php
@@ -124,6 +124,11 @@ if (isset($_COOKIE['shaarli']) && !SessionManager::checkId($_COOKIE['shaarli']))
 $conf = new ConfigManager();
 $sessionManager = new SessionManager($_SESSION, $conf);
 
+// LC_MESSAGES isn't defined without php-intl, in this case use LC_COLLATE locale instead.
+if (! defined('LC_MESSAGES')) {
+    define('LC_MESSAGES', LC_COLLATE);
+}
+
 // Sniff browser language and set date format accordingly.
 if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
     autoLocale($_SERVER['HTTP_ACCEPT_LANGUAGE']);