use Dotclear L10n Helper

This commit is contained in:
Jean-Christian Paul Denis 2023-04-08 17:43:34 +02:00
parent aeb9bb3353
commit 4cfd2a398e
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
3 changed files with 18 additions and 18 deletions

View File

@ -19,9 +19,9 @@ use dcModuleDefine;
use dcThemes; use dcThemes;
use Dotclear\Helper\File\Files; use Dotclear\Helper\File\Files;
use Dotclear\Helper\File\Path; use Dotclear\Helper\File\Path;
use Dotclear\Helper\L10n;
use Dotclear\Helper\Text; use Dotclear\Helper\Text;
use Exception; use Exception;
use l10n;
/** /**
* Translater tools. * Translater tools.
@ -112,7 +112,7 @@ class Translater extends Settings
*/ */
public function getLang(TranslaterModule $module, string $lang): TranslaterLang public function getLang(TranslaterModule $module, string $lang): TranslaterLang
{ {
if (!l10n::isCode($lang)) { if (!L10n::isCode($lang)) {
throw new Exception( throw new Exception(
sprintf(__('Failed find language %s'), $lang) sprintf(__('Failed find language %s'), $lang)
); );

View File

@ -17,7 +17,7 @@ namespace Dotclear\Plugin\translater;
use dcModuleDefine; use dcModuleDefine;
use Dotclear\Helper\File\Files; use Dotclear\Helper\File\Files;
use Dotclear\Helper\File\Path; use Dotclear\Helper\File\Path;
use l10n; use Dotclear\Helper\L10n;
class TranslaterLang class TranslaterLang
{ {
@ -37,8 +37,8 @@ class TranslaterLang
{ {
$this->module = $module; $this->module = $module;
$this->code = $lang; $this->code = $lang;
$this->name = l10n::getLanguageName($lang); $this->name = L10n::getLanguageName($lang);
$this->plural = explode(':', l10n::getLanguagePluralExpression($lang)); $this->plural = explode(':', L10n::getLanguagePluralExpression($lang));
} }
/** /**
@ -174,7 +174,7 @@ class TranslaterLang
$path = Path::clean($this->module->locales . DIRECTORY_SEPARATOR . $file); $path = Path::clean($this->module->locales . DIRECTORY_SEPARATOR . $file);
if (Translater::isPoFile($file)) { if (Translater::isPoFile($file)) {
$po = l10n::parsePoFile($path); $po = L10n::parsePoFile($path);
if (!is_array($po)) { if (!is_array($po)) {
continue; continue;
} }

View File

@ -21,9 +21,9 @@ use Dotclear\Helper\File\Path;
use Dotclear\Helper\File\Zip\Unzip; use Dotclear\Helper\File\Zip\Unzip;
use Dotclear\Helper\File\Zip\Zip; use Dotclear\Helper\File\Zip\Zip;
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Dotclear\Helper\L10n;
use Exception; use Exception;
use dt; use dt;
use l10n;
/** /**
* Translater tools. * Translater tools.
@ -157,7 +157,7 @@ class TranslaterModule
if (is_dir($backup . '/' . $file) if (is_dir($backup . '/' . $file)
|| !$is_backup || !$is_backup
|| !l10n::isCode($m[1]) || !L10n::isCode($m[1])
) { ) {
continue; continue;
} }
@ -166,7 +166,7 @@ class TranslaterModule
$res[] = $file; $res[] = $file;
} else { } else {
$res[$m[1]][$file]['code'] = $m[1]; $res[$m[1]][$file]['code'] = $m[1];
$res[$m[1]][$file]['name'] = l10n::getLanguageName($m[1]); $res[$m[1]][$file]['name'] = L10n::getLanguageName($m[1]);
$res[$m[1]][$file]['path'] = Path::info($backup . '/' . $file); $res[$m[1]][$file]['path'] = Path::info($backup . '/' . $file);
$res[$m[1]][$file]['time'] = filemtime($backup . '/' . $file); $res[$m[1]][$file]['time'] = filemtime($backup . '/' . $file);
$res[$m[1]][$file]['size'] = filesize($backup . '/' . $file); $res[$m[1]][$file]['size'] = filesize($backup . '/' . $file);
@ -270,7 +270,7 @@ class TranslaterModule
if (!file_exists($backup . '/' . $file) if (!file_exists($backup . '/' . $file)
|| !$is_backup || !$is_backup
|| !l10n::isCode($m[1]) || !L10n::isCode($m[1])
) { ) {
return false; return false;
} }
@ -426,7 +426,7 @@ class TranslaterModule
if ($is_file) { if ($is_file) {
$module = $f[1] == $this->id ? $f[1] : false; $module = $f[1] == $this->id ? $f[1] : false;
$lang = l10n::isCode($f[2]) ? $f[2] : false; $lang = L10n::isCode($f[2]) ? $f[2] : false;
$group = in_array($f[3], My::l10nGroupsCombo()) ? $f[3] : false; $group = in_array($f[3], My::l10nGroupsCombo()) ? $f[3] : false;
$ext = Translater::isLangphpFile($f[4]) || Translater::isPoFile($f[4]) ? $f[4] : false; $ext = Translater::isLangphpFile($f[4]) || Translater::isPoFile($f[4]) ? $f[4] : false;
} }
@ -471,14 +471,14 @@ class TranslaterModule
continue; continue;
} }
if (!l10n::isCode($m[1])) { if (!L10n::isCode($m[1])) {
continue; continue;
} }
if ($return_path) { if ($return_path) {
$res[$m[1]][] = $file; // Path $res[$m[1]][] = $file; // Path
} else { } else {
$res[$m[1]] = l10n::getLanguageName($m[1]); // Lang name $res[$m[1]] = L10n::getLanguageName($m[1]); // Lang name
} }
} }
@ -502,7 +502,7 @@ class TranslaterModule
*/ */
public function getUnusedLangs(): array public function getUnusedLangs(): array
{ {
return array_diff(l10n::getISOcodes(true, false), $this->getUsedLangs()); return array_diff(L10n::getISOcodes(true, false), $this->getUsedLangs());
} }
/** /**
@ -514,7 +514,7 @@ class TranslaterModule
*/ */
public function addLang(string $lang, string $from_lang = ''): bool public function addLang(string $lang, string $from_lang = ''): bool
{ {
if (!l10n::isCode($lang)) { if (!L10n::isCode($lang)) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Unknow language %s'), __('Unknow language %s'),
$lang $lang
@ -569,7 +569,7 @@ class TranslaterModule
*/ */
public function updLang(string $lang, array $msgs): void public function updLang(string $lang, array $msgs): void
{ {
if (!l10n::isCode($lang)) { if (!L10n::isCode($lang)) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Unknow language %s'), __('Unknow language %s'),
$lang $lang
@ -636,7 +636,7 @@ class TranslaterModule
public function delLang(string $lang, bool $del_empty_dir = true): bool public function delLang(string $lang, bool $del_empty_dir = true): bool
{ {
# Path is right formed # Path is right formed
if (!l10n::isCode($lang)) { if (!L10n::isCode($lang)) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Unknow language %s'), __('Unknow language %s'),
$lang $lang
@ -791,7 +791,7 @@ class TranslaterModule
$content .= '// Translated with Translater - ' . dcCore::app()->plugins->moduleInfo(My::id(), 'version') . "\n\n"; $content .= '// Translated with Translater - ' . dcCore::app()->plugins->moduleInfo(My::id(), 'version') . "\n\n";
} }
l10n::generatePhpFileFromPo(implode(DIRECTORY_SEPARATOR, [$this->locales, $lang->code, $group]), $content); L10n::generatePhpFileFromPo(implode(DIRECTORY_SEPARATOR, [$this->locales, $lang->code, $group]), $content);
} }
//@} //@}
} }