X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FLanguages.php;h=7177db2ccda5fcd6c190d70e3383d091b6bda48a;hb=150f2a0f2443e1aa5d993dd2e7126a2db86fe591;hp=6a6247c7f1ea79c9fea9c467bc2d61617f1e70b7;hpb=f211e417bf637b8a83988175c29ee072c69f7642;p=github%2Fshaarli%2FShaarli.git diff --git a/application/Languages.php b/application/Languages.php index 6a6247c7..7177db2c 100644 --- a/application/Languages.php +++ b/application/Languages.php @@ -3,7 +3,6 @@ namespace Shaarli; use Gettext\GettextTranslator; -use Gettext\Merge; use Gettext\Translations; use Gettext\Translator; use Gettext\TranslatorInterface; @@ -42,7 +41,7 @@ class Languages /** * Core translations domain */ - const DEFAULT_DOMAIN = 'shaarli'; + public const DEFAULT_DOMAIN = 'shaarli'; /** * @var TranslatorInterface @@ -77,7 +76,8 @@ class Languages $this->language = $confLanguage; } - if (! extension_loaded('gettext') + if ( + ! extension_loaded('gettext') || in_array($this->conf->get('translation.mode', 'auto'), ['auto', 'php']) ) { $this->initPhpTranslator(); @@ -99,7 +99,7 @@ class Languages $this->translator->loadDomain(self::DEFAULT_DOMAIN, 'inc/languages'); // Default extension translation from the current theme - $themeTransFolder = rtrim($this->conf->get('raintpl_tpl'), '/') .'/'. $this->conf->get('theme') .'/language'; + $themeTransFolder = rtrim($this->conf->get('raintpl_tpl'), '/') . '/' . $this->conf->get('theme') . '/language'; if (is_dir($themeTransFolder)) { $this->translator->loadDomain($this->conf->get('theme'), $themeTransFolder, false); } @@ -122,7 +122,9 @@ class Languages $translations = new Translations(); // Core translations try { - $translations = $translations->addFromPoFile('inc/languages/'. $this->language .'/LC_MESSAGES/shaarli.po'); + $translations = $translations->addFromPoFile( + 'inc/languages/' . $this->language . '/LC_MESSAGES/shaarli.po' + ); $translations->setDomain('shaarli'); $this->translator->loadTranslations($translations); } catch (\InvalidArgumentException $e) { @@ -130,11 +132,11 @@ class Languages // Default extension translation from the current theme $theme = $this->conf->get('theme'); - $themeTransFolder = rtrim($this->conf->get('raintpl_tpl'), '/') .'/'. $theme .'/language'; + $themeTransFolder = rtrim($this->conf->get('raintpl_tpl'), '/') . '/' . $theme . '/language'; if (is_dir($themeTransFolder)) { try { $translations = Translations::fromPoFile( - $themeTransFolder .'/'. $this->language .'/LC_MESSAGES/'. $theme .'.po' + $themeTransFolder . '/' . $this->language . '/LC_MESSAGES/' . $theme . '.po' ); $translations->setDomain($theme); $this->translator->loadTranslations($translations); @@ -149,7 +151,9 @@ class Languages } try { - $extension = Translations::fromPoFile($translationPath . $this->language .'/LC_MESSAGES/'. $domain .'.po'); + $extension = Translations::fromPoFile( + $translationPath . $this->language . '/LC_MESSAGES/' . $domain . '.po' + ); $extension->setDomain($domain); $this->translator->loadTranslations($extension); } catch (\InvalidArgumentException $e) { @@ -178,9 +182,11 @@ class Languages { return [ 'auto' => t('Automatic'), + 'de' => t('German'), 'en' => t('English'), 'fr' => t('French'), - 'de' => t('German'), + 'jp' => t('Japanese'), + 'ru' => t('Russian'), ]; } }