ensure English is always added to available languages, fixes #1208

bug got introduced in 3668f1e3f4 and
started affecting release after 896a49c8cf
This commit is contained in:
El RIDO 2023-12-09 11:39:53 +01:00
parent 826444bef7
commit a7f720d825
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
3 changed files with 16 additions and 5 deletions

View file

@ -1,5 +1,8 @@
# PrivateBin version history # PrivateBin version history
## 1.6.2 (not yet released)
* FIXED: English not selectable when languageselection enabled (#1208)
## 1.6.1 (2023-12-04) ## 1.6.1 (2023-12-04)
* ADDED: Right-To-Left (RTL) support for Arabic & Hebrew (#1174) * ADDED: Right-To-Left (RTL) support for Arabic & Hebrew (#1174)
* CHANGED: Upgrading libraries to: DOMpurify 3.0.6 * CHANGED: Upgrading libraries to: DOMpurify 3.0.6

View file

@ -13,6 +13,7 @@
namespace PrivateBin\Data; namespace PrivateBin\Data;
use Exception; use Exception;
use GlobIterator;
use PrivateBin\Json; use PrivateBin\Json;
/** /**
@ -394,7 +395,7 @@ class Filesystem extends AbstractData
public function getAllPastes() public function getAllPastes()
{ {
$pastes = array(); $pastes = array();
foreach (new \GlobIterator($this->_path . self::PASTE_FILE_PATTERN) as $file) { foreach (new GlobIterator($this->_path . self::PASTE_FILE_PATTERN) as $file) {
if ($file->isFile()) { if ($file->isFile()) {
$pastes[] = $file->getBasename('.php'); $pastes[] = $file->getBasename('.php');
} }

View file

@ -12,6 +12,9 @@
namespace PrivateBin; namespace PrivateBin;
use AppendIterator;
use GlobIterator;
/** /**
* I18n * I18n
* *
@ -193,10 +196,14 @@ class I18n
public static function getAvailableLanguages() public static function getAvailableLanguages()
{ {
if (count(self::$_availableLanguages) == 0) { if (count(self::$_availableLanguages) == 0) {
$i18n = dir(self::_getPath()); self::$_availableLanguages[] = 'en'; // en.json is not part of the release archive
while (false !== ($file = $i18n->read())) { $languageIterator = new AppendIterator();
if (preg_match('/^([a-z]{2,3}).json$/', $file, $match) === 1) { $languageIterator->append(new GlobIterator(self::_getPath('??.json')));
self::$_availableLanguages[] = $match[1]; $languageIterator->append(new GlobIterator(self::_getPath('???.json'))); // for jbo
foreach ($languageIterator as $file) {
$language = $file->getBasename('.json');
if ($language != 'en') {
self::$_availableLanguages[] = $language;
} }
} }
} }