try translater on itself ! add fr translation

master
Jean-Christian Paul Denis 2021-09-25 16:32:04 +02:00
parent c89b162336
commit 47b1901fb9
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
4 changed files with 19 additions and 26 deletions

View File

@ -19,11 +19,6 @@ $translater = new dcTranslater($core);
if (!empty($_POST['save'])) { if (!empty($_POST['save'])) {
try { try {
if (empty($_POST['write_po']) && empty($_POST['write_langphp'])) {
throw new Exception(
__('You must at least choose one file format to write')
);
}
foreach($translater->getDefaultSettings() as $k => $v) { foreach($translater->getDefaultSettings() as $k => $v) {
$translater->setSetting($k, (isset($_POST[$k]) ? $_POST[$k] : '')); $translater->setSetting($k, (isset($_POST[$k]) ? $_POST[$k] : ''));
} }
@ -93,7 +88,7 @@ form::combo('start_page',[
], $translater->start_page) . '</p> ], $translater->start_page) . '</p>
<p><label for="plugin_menu">' . <p><label for="plugin_menu">' .
form::checkbox('plugin_menu', '1', $translater->plugin_menu) . form::checkbox('plugin_menu', '1', $translater->plugin_menu) .
__('Enable menu on extensions page') . '</label></p> __('Enable menu on plugins page') . '</label></p>
<p><label for="theme_menu">' . <p><label for="theme_menu">' .
form::checkbox('theme_menu', '1', $translater->theme_menu) . form::checkbox('theme_menu', '1', $translater->theme_menu) .
__('Enable menu on themes page') . '</label></p> __('Enable menu on themes page') . '</label></p>

View File

@ -115,7 +115,7 @@ class dcTranslaterModule
} }
if (!$dir && $throw) { if (!$dir && $throw) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Cannot find backups folder for module %s'), $id __('Failed to find backups folder for module %s'), $id
)); ));
} }
@ -173,7 +173,7 @@ class dcTranslaterModule
if (!is_dir($this->prop['locales'] . '/' . $lang)) { if (!is_dir($this->prop['locales'] . '/' . $lang)) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Cannot find language folder %s for module %s') ,$lang, $this->prop['id'] __('Failed to find language %s'), $lang
)); ));
} }
@ -217,7 +217,7 @@ class dcTranslaterModule
if (!file_exists($backup . '/' . $file)) { if (!file_exists($backup . '/' . $file)) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Cannot find backup file %s'), $file __('Failed to find file %s'), $file
)); ));
} }
@ -256,7 +256,7 @@ class dcTranslaterModule
if (!files::isDeletable($backup . '/' . $file)) { if (!files::isDeletable($backup . '/' . $file)) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Cannot delete backup file %s'), $file __('Failed to delete file %s'), $file
)); ));
} }
@ -317,7 +317,7 @@ class dcTranslaterModule
)); ));
} elseif (!$done) { } elseif (!$done) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Nothing to import for these modules in pack %s'), $zip_file['name'] __('Nothing to import from %s'), $zip_file['name']
)); ));
} }
return true; return true;
@ -326,14 +326,13 @@ class dcTranslaterModule
/** /**
* Export (to output) language pack * Export (to output) language pack
* *
* @param array $modules The modules to work on
* @param array $langs Langs to export * @param array $langs Langs to export
*/ */
public function exportPack(array $langs) public function exportPack(array $langs)
{ {
if (empty($langs)) { if (empty($langs)) {
throw new Exception( throw new Exception(
__('Wrong export query') __('Nothing to export')
); );
} }
@ -490,7 +489,7 @@ class dcTranslaterModule
{ {
if (!l10n::isCode($lang)) { if (!l10n::isCode($lang)) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Wrong language %s'), $lang __('Unknow language %s'), $lang
)); ));
} }
@ -505,7 +504,7 @@ class dcTranslaterModule
if (!empty($from_lang) && !isset($langs[$from_lang])) { if (!empty($from_lang) && !isset($langs[$from_lang])) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Cannot copy file from language %s'), $from_lang __('Failed to copy file from language %s'), $from_lang
)); ));
} }
@ -539,7 +538,7 @@ class dcTranslaterModule
{ {
if (!l10n::isCode($lang)) { if (!l10n::isCode($lang)) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Wrong language %s'), $lang __('Unknow language %s'), $lang
)); ));
} }
@ -580,8 +579,7 @@ class dcTranslaterModule
if (empty($rs)) { if (empty($rs)) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('No string to write, language %s deleted for module %s'), __('No string to write, language %s deleted'), $lang
$lang, $id
)); ));
} }
@ -603,14 +601,14 @@ class dcTranslaterModule
# Path is right formed # Path is right formed
if (!l10n::isCode($lang)) { if (!l10n::isCode($lang)) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Wrong language %s'), $lang __('Unknow language %s'), $lang
)); ));
} }
$files = $this->getLangs(true); $files = $this->getLangs(true);
if (!isset($files[$lang])) { if (!isset($files[$lang])) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Cannot find language folder %s'), $lang __('Failed to find language %s'), $lang
)); ));
} }
@ -709,13 +707,13 @@ class dcTranslaterModule
if (is_dir($path['dirname']) && !is_writable($path['dirname']) if (is_dir($path['dirname']) && !is_writable($path['dirname'])
|| file_exists($file) && !is_writable($file)) { || file_exists($file) && !is_writable($file)) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Cannot grant write acces on lang file %s'), $file __('Failed to grant write acces on file %s'), $file
)); ));
} }
if (!($f = @files::putContent($file, $content))) { if (!($f = @files::putContent($file, $content))) {
throw new Exception(sprintf( throw new Exception(sprintf(
__('Cannot write lang file %s'), $file __('Failed to write file %s'), $file
)); ));
} }
} }

View File

@ -293,7 +293,7 @@ class dcTranslater
{ {
if (!isset($this->modules[$type][$id])) { if (!isset($this->modules[$type][$id])) {
throw new Exception( throw new Exception(
sprintf(__('Cannot find module %s'), $id) sprintf(__('Failed to find module %s'), $id)
); );
return false; return false;
} }
@ -311,7 +311,7 @@ class dcTranslater
{ {
if (!l10n::isCode($lang)) { if (!l10n::isCode($lang)) {
throw new Exception( throw new Exception(
sprintf(__('Cannot find lang %s'), $lang) sprintf(__('Failed find language %s'), $lang)
); );
return false; return false;
} }

View File

@ -170,7 +170,7 @@ try {
} }
echo echo
'<html><head><title>' . __('translater') . '</title>' . '<html><head><title>' . __('Translater') . '</title>' .
dcPage::jsPageTabs() . dcPage::jsPageTabs() .
dcPage::cssLoad(dcPage::getPF('translater/css/translater.css')) . dcPage::cssLoad(dcPage::getPF('translater/css/translater.css')) .
dcpage::jsJson('translater', [ dcpage::jsJson('translater', [
@ -551,7 +551,7 @@ if (empty($module) && $type != '') {
form::combo('multigroup', $allowed_l10n_groups) . '</label></p>' . form::combo('multigroup', $allowed_l10n_groups) . '</label></p>' .
'</div>' . '</div>' .
'<p class="col right">' . '<p class="col right">' .
'<input id="do-action" type="submit" value="' . __('Save (s)') . '" accesskey="s" /></p>' . '<input id="do-action" type="submit" value="' . __('Save') . ' (s)" accesskey="s" /></p>' .
$core->formNonce() . $core->formNonce() .
form::hidden(['code'], $lang->code) . form::hidden(['code'], $lang->code) .
$core->adminurl->getHiddenFormFields( $core->adminurl->getHiddenFormFields(