aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2018-06-09 15:57:17 +0200
committerGravatar GitHub <noreply@github.com> 2018-06-09 15:57:17 +0200
commit32676d59a386fe067ae0beac0287c700274f3d57 (patch)
tree3023cafc8b0d1fbc075aa47fd7d14dcfbb6e5985 /lib
parent70bb228e1dda583791be1281418b1c49ac7d31bf (diff)
Minz fix translate (#1927)
Fix https://github.com/FreshRSS/FreshRSS/issues/1797
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/Translate.php26
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/Minz/Translate.php b/lib/Minz/Translate.php
index d9cd59f7e..db76e9214 100644
--- a/lib/Minz/Translate.php
+++ b/lib/Minz/Translate.php
@@ -64,12 +64,16 @@ class Minz_Translate {
$list_langs = array();
foreach (self::$path_list as $path) {
- $path_langs = array_values(array_diff(
- scandir($path),
- array('..', '.')
- ));
-
- $list_langs = array_merge($list_langs, $path_langs);
+ $scan = scandir($path);
+ if (is_array($scan)) {
+ $path_langs = array_values(array_diff(
+ $scan,
+ array('..', '.')
+ ));
+ if (is_array($path_langs)) {
+ $list_langs = array_merge($list_langs, $path_langs);
+ }
+ }
}
return array_unique($list_langs);
@@ -80,12 +84,10 @@ class Minz_Translate {
* @param $path a path containing i18n directories (e.g. ./en/, ./fr/).
*/
public static function registerPath($path) {
- if (in_array($path, self::$path_list)) {
- return;
+ if (!in_array($path, self::$path_list) && is_dir($path)) {
+ self::$path_list[] = $path;
+ self::loadLang($path);
}
-
- self::$path_list[] = $path;
- self::loadLang($path);
}
/**
@@ -94,7 +96,7 @@ class Minz_Translate {
*/
private static function loadLang($path) {
$lang_path = $path . '/' . self::$lang_name;
- if (!file_exists($lang_path) || is_null(self::$lang_name)) {
+ if (!file_exists($lang_path) || self::$lang_name == '') {
// The lang path does not exist, nothing more to do.
return;
}