From 47b1901fb9311ffaf02c1c8a126804544d72b939 Mon Sep 17 00:00:00 2001
From: Jean-Christian Denis
Date: Sat, 25 Sep 2021 16:32:04 +0200
Subject: [PATCH] try translater on itself ! add fr translation
---
_config.php | 7 +------
inc/class.dc.translater.module.php | 30 ++++++++++++++----------------
inc/class.dc.translater.php | 4 ++--
index.php | 4 ++--
4 files changed, 19 insertions(+), 26 deletions(-)
diff --git a/_config.php b/_config.php
index 239bd0f..e2d3250 100644
--- a/_config.php
+++ b/_config.php
@@ -19,11 +19,6 @@ $translater = new dcTranslater($core);
if (!empty($_POST['save'])) {
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) {
$translater->setSetting($k, (isset($_POST[$k]) ? $_POST[$k] : ''));
}
@@ -93,7 +88,7 @@ form::combo('start_page',[
], $translater->start_page) . '
+__('Enable menu on plugins page') . '
diff --git a/inc/class.dc.translater.module.php b/inc/class.dc.translater.module.php
index 8e7faf3..06dcb94 100644
--- a/inc/class.dc.translater.module.php
+++ b/inc/class.dc.translater.module.php
@@ -115,7 +115,7 @@ class dcTranslaterModule
}
if (!$dir && $throw) {
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)) {
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)) {
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)) {
throw new Exception(sprintf(
- __('Cannot delete backup file %s'), $file
+ __('Failed to delete file %s'), $file
));
}
@@ -317,7 +317,7 @@ class dcTranslaterModule
));
} elseif (!$done) {
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;
@@ -326,14 +326,13 @@ class dcTranslaterModule
/**
* Export (to output) language pack
*
- * @param array $modules The modules to work on
* @param array $langs Langs to export
*/
public function exportPack(array $langs)
{
if (empty($langs)) {
throw new Exception(
- __('Wrong export query')
+ __('Nothing to export')
);
}
@@ -490,7 +489,7 @@ class dcTranslaterModule
{
if (!l10n::isCode($lang)) {
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])) {
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)) {
throw new Exception(sprintf(
- __('Wrong language %s'), $lang
+ __('Unknow language %s'), $lang
));
}
@@ -580,8 +579,7 @@ class dcTranslaterModule
if (empty($rs)) {
throw new Exception(sprintf(
- __('No string to write, language %s deleted for module %s'),
- $lang, $id
+ __('No string to write, language %s deleted'), $lang
));
}
@@ -603,14 +601,14 @@ class dcTranslaterModule
# Path is right formed
if (!l10n::isCode($lang)) {
throw new Exception(sprintf(
- __('Wrong language %s'), $lang
+ __('Unknow language %s'), $lang
));
}
$files = $this->getLangs(true);
if (!isset($files[$lang])) {
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'])
|| file_exists($file) && !is_writable($file)) {
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))) {
throw new Exception(sprintf(
- __('Cannot write lang file %s'), $file
+ __('Failed to write file %s'), $file
));
}
}
diff --git a/inc/class.dc.translater.php b/inc/class.dc.translater.php
index c0ada4e..d35bb50 100644
--- a/inc/class.dc.translater.php
+++ b/inc/class.dc.translater.php
@@ -293,7 +293,7 @@ class dcTranslater
{
if (!isset($this->modules[$type][$id])) {
throw new Exception(
- sprintf(__('Cannot find module %s'), $id)
+ sprintf(__('Failed to find module %s'), $id)
);
return false;
}
@@ -311,7 +311,7 @@ class dcTranslater
{
if (!l10n::isCode($lang)) {
throw new Exception(
- sprintf(__('Cannot find lang %s'), $lang)
+ sprintf(__('Failed find language %s'), $lang)
);
return false;
}
diff --git a/index.php b/index.php
index 9dc2648..33292a0 100644
--- a/index.php
+++ b/index.php
@@ -170,7 +170,7 @@ try {
}
echo
-'' . __('translater') . '' .
+'' . __('Translater') . '' .
dcPage::jsPageTabs() .
dcPage::cssLoad(dcPage::getPF('translater/css/translater.css')) .
dcpage::jsJson('translater', [
@@ -551,7 +551,7 @@ if (empty($module) && $type != '') {
form::combo('multigroup', $allowed_l10n_groups) . '' .
'' .
'' .
- '
' .
+ '' .
$core->formNonce() .
form::hidden(['code'], $lang->code) .
$core->adminurl->getHiddenFormFields(