aboutsummaryrefslogtreecommitdiff
path: root/app/FreshRSS.php
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2020-06-05 10:10:46 +0200
committerGravatar GitHub <noreply@github.com> 2020-06-05 10:10:46 +0200
commit36bda2e715ed822cc495ff419ad565084e241f43 (patch)
tree6a4fd79cd42ab76cab2338eedb02f787e4e2c3a8 /app/FreshRSS.php
parentd4554fa087f9057610085ca685cd8fb79d8f2bd0 (diff)
Add language detection when the user is not logged in (#3022)
Before, when the user was not logged in, pages where translated with the '_' user language. Now, they are translated with the user preferred language if there is one supported by FreshRSS or with the system default language.
Diffstat (limited to 'app/FreshRSS.php')
-rw-r--r--app/FreshRSS.php11
1 files changed, 7 insertions, 4 deletions
diff --git a/app/FreshRSS.php b/app/FreshRSS.php
index 32c3c39d0..ee454d7fd 100644
--- a/app/FreshRSS.php
+++ b/app/FreshRSS.php
@@ -68,7 +68,7 @@ class FreshRSS extends Minz_FrontController {
// Basic protection against XSRF attacks
FreshRSS_Auth::removeAccess();
$http_referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
- Minz_Translate::init('en'); //TODO: Better choice of fallback language
+ self::initI18n();
Minz_Error::error(403, array('error' => array(
_t('feedback.access.denied'),
' [HTTP_REFERER=' . htmlspecialchars($http_referer, ENT_NOQUOTES, 'UTF-8') . ']'
@@ -80,7 +80,7 @@ class FreshRSS extends Minz_FrontController {
!FreshRSS_Auth::hasAccess('admin'))
)) {
// Token-based protection against XSRF attacks, except for the login or self-create user forms
- Minz_Translate::init('en'); //TODO: Better choice of fallback language
+ self::initI18n();
Minz_Error::error(403, array('error' => array(
_t('feedback.access.denied'),
' [CSRF]'
@@ -90,8 +90,11 @@ class FreshRSS extends Minz_FrontController {
}
private static function initI18n() {
- Minz_Session::_param('language', FreshRSS_Context::$user_conf->language);
- Minz_Translate::init(FreshRSS_Context::$user_conf->language);
+ $selected_language = FreshRSS_Auth::hasAccess() ? FreshRSS_Context::$user_conf->language : null;
+ $language = Minz_Translate::getLanguage($selected_language, Minz_Request::getPreferredLanguages(), FreshRSS_Context::$system_conf->language);
+
+ Minz_Session::_param('language', $language);
+ Minz_Translate::init($language);
}
public static function loadStylesAndScripts() {