namespace Friendica\Core\Config\Repository;
+use Friendica\App\Mode;
use Friendica\Core\Config\Exception\ConfigPersistenceException;
use Friendica\Core\Config\Util\ValueConversion;
use Friendica\Database\Database;
{
/** @var Database */
protected $db;
+ /** @var Mode */
+ protected $mode;
- public function __construct(Database $db)
+ public function __construct(Database $db, Mode $mode)
{
- $this->db = $db;
+ $this->db = $db;
+ $this->mode = $mode;
}
protected static $table_name = 'config';
*/
public function isConnected(): bool
{
- return $this->db->isConnected();
+ return $this->db->isConnected() && !$this->mode->isInstall();
}
/**
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Database\Database;
use Friendica\Util\Strings;
-use Psr\Log\LoggerInterface;
/**
* Provide Language, Translation, and Localization functions to the application
{
/** @var string The default language */
const DEFAULT = 'en';
+ /** @var string[] The language names in their language */
+ const LANG_NAMES = [
+ 'ar' => 'العربية',
+ 'bg' => 'Български',
+ 'ca' => 'Català',
+ 'cs' => 'Česky',
+ 'de' => 'Deutsch',
+ 'en-gb' => 'English (United Kingdom)',
+ 'en-us' => 'English (United States)',
+ 'en' => 'English (Default)',
+ 'eo' => 'Esperanto',
+ 'es' => 'Español',
+ 'et' => 'Eesti',
+ 'fi-fi' => 'Suomi',
+ 'fr' => 'Français',
+ 'hu' => 'Magyar',
+ 'is' => 'Íslenska',
+ 'it' => 'Italiano',
+ 'ja' => '日本語',
+ 'nb-no' => 'Norsk bokmål',
+ 'nl' => 'Nederlands',
+ 'pl' => 'Polski',
+ 'pt-br' => 'Português Brasileiro',
+ 'ro' => 'Română',
+ 'ru' => 'Русский',
+ 'sv' => 'Svenska',
+ 'zh-cn' => '简体中文',
+ ];
/**
* A string indicating the current language used for translation:
*/
private $dba;
- /**
- * @var LoggerInterface
- */
- private $logger;
-
- public function __construct(IManageConfigValues $config, Database $dba, LoggerInterface $logger, IHandleSessions $session, array $server, array $get)
+ public function __construct(IManageConfigValues $config, Database $dba, IHandleSessions $session, array $server, array $get)
{
$this->dba = $dba;
- $this->logger = $logger;
$this->loadTranslationTable(L10n::detectLanguage($server, $get, $config->get('system', 'language', self::DEFAULT)));
$this->setSessionVariable($session);
*
* Scans the view/lang directory for the existence of "strings.php" files, and
* returns an alphabetical list of their folder names (@-char language codes).
- * Adds the english language if it's missing from the list.
+ * Adds the english language if it's missing from the list. Folder names are
+ * replaced by nativ language names.
*
- * Ex: array('de' => 'de', 'en' => 'en', 'fr' => 'fr', ...)
+ * Ex: array('de' => 'Deutsch', 'en' => 'English', 'fr' => 'Français', ...)
*
* @return array
*/
asort($strings_file_paths);
foreach ($strings_file_paths as $strings_file_path) {
$path_array = explode('/', $strings_file_path);
- $langs[$path_array[2]] = $path_array[2];
+ $langs[$path_array[2]] = self::LANG_NAMES[$path_array[2]] ?? $path_array[2];
}
}
return $langs;
namespace Friendica\Core\PConfig\Repository;
+use Friendica\App\Mode;
use Friendica\Core\Config\Util\ValueConversion;
use Friendica\Core\PConfig\Exception\PConfigPersistenceException;
use Friendica\Database\Database;
/** @var Database */
protected $db;
+ /** @var Mode */
+ protected $mode;
- public function __construct(Database $db)
+ public function __construct(Database $db, Mode $mode)
{
- $this->db = $db;
+ $this->db = $db;
+ $this->mode = $mode;
}
/**
*/
public function isConnected(): bool
{
- return $this->db->isConnected();
+ return $this->db->isConnected() & !$this->mode->isInstall();
}
/**
namespace Friendica\Test\src\Core\Storage\Repository;
use Dice\Dice;
+use Friendica\App\Mode;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Config\Type\PreloadConfig;
use Friendica\Core\Hook;
$this->dba = new StaticDatabase($configCache, $profiler, $this->logger);
- $configModel = new Repository\Config($this->dba);
+ $configModel = new Repository\Config($this->dba, new Mode(Mode::DBCONFIGAVAILABLE));
$this->config = new PreloadConfig($configCache, $configModel);
$this->config->set('storage', 'name', 'Database');
$this->config->set('storage', 'filesystem_path', $this->root->getChild(Type\FilesystemConfig::DEFAULT_BASE_FOLDER)->url());