namespace Shaarli;
use Gettext\GettextTranslator;
-use Gettext\Merge;
use Gettext\Translations;
use Gettext\Translator;
use Gettext\TranslatorInterface;
/**
* Core translations domain
*/
- const DEFAULT_DOMAIN = 'shaarli';
+ public const DEFAULT_DOMAIN = 'shaarli';
/**
* @var TranslatorInterface
$this->language = $confLanguage;
}
- if (! extension_loaded('gettext')
+ if (
+ ! extension_loaded('gettext')
|| in_array($this->conf->get('translation.mode', 'auto'), ['auto', 'php'])
) {
$this->initPhpTranslator();
/**
* Initialize the translator using php gettext extension (gettext dependency act as a wrapper).
*/
- protected function initGettextTranslator ()
+ protected function initGettextTranslator()
{
$this->translator = new GettextTranslator();
$this->translator->setLanguage($this->language);
$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);
}
$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) {}
+ } catch (\InvalidArgumentException $e) {
+ }
// 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);
- } catch (\InvalidArgumentException $e) {}
+ } catch (\InvalidArgumentException $e) {
+ }
}
// Extension translations (plugins, themes, etc.).
}
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) {}
+ } catch (\InvalidArgumentException $e) {
+ }
}
}
{
return [
'auto' => t('Automatic'),
+ 'de' => t('German'),
'en' => t('English'),
'fr' => t('French'),
- 'de' => t('German'),
+ 'jp' => t('Japanese'),
+ 'ru' => t('Russian'),
];
}
}