Add option to override strings during import

Fixes #47
This commit is contained in:
Dmitriy Simushev 2014-08-05 13:38:03 +00:00
parent cabdaed21d
commit 668e724a01
2 changed files with 15 additions and 1 deletions

View File

@ -41,6 +41,8 @@ class TranslationImportController extends AbstractController
$target = get_current_locale();
}
$override = (bool)$request->request->get('override', false);
$page = array(
// Use errors list stored in the request. We need to do so to have
// an ability to pass the request from other actions.
@ -60,6 +62,7 @@ class TranslationImportController extends AbstractController
$page['stored'] = $request->query->has('stored');
$page['localesList'] = $locales_list;
$page['formtarget'] = $target;
$page['formoverride'] = $override;
$page['title'] = getlocal('Translations import');
$page['menuid'] = 'translation';
$page = array_merge($page, prepare_menu($operator));
@ -87,6 +90,8 @@ class TranslationImportController extends AbstractController
$target = get_current_locale();
}
$override = (bool)$request->request->get('override', false);
// Validate uploaded file
$file = $request->files->get('translation_file');
if ($file) {
@ -107,7 +112,7 @@ class TranslationImportController extends AbstractController
if (count($errors) == 0) {
try {
// Try to import new messages.
import_messages($target, $file->getRealPath());
import_messages($target, $file->getRealPath(), $override);
// The file is not needed any more. Remove it.
unlink($file->getRealPath());

View File

@ -35,6 +35,15 @@
</div>
<div class="fieldForm">
<div class="field">
<label for="override" class="flabel">{{l10n "Override existing translations"}}</label>
<div class="fvalue">
<input id="override" type="checkbox" name="override" value="on"{{#if formoverride}} checked="checked"{{/if}}/>
</div>
<label for="override" class="fdescr"> &mdash; {{l10n "Replaces translated strings in the database with values from the imported file."}}</label>
<br clear="all"/>
</div>
<div class="field">
<label for="translation_file" class="flabel">
{{l10n "Upload translation"}}<span class="required">*</span>