Improve translation handling
This commit is contained in:
parent
fd547bb485
commit
4504d5bf4c
|
|
@ -107,6 +107,17 @@ class FormController extends ControllerBehavior
|
|||
*/
|
||||
if ($this->controller->isClassExtendedWith('Backend.Behaviors.RelationController'))
|
||||
$this->controller->initRelation($model);
|
||||
|
||||
$this->prepareVars($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares common form data
|
||||
*/
|
||||
protected function prepareVars($model)
|
||||
{
|
||||
$this->controller->vars['formModel'] = $model;
|
||||
$this->controller->vars['formRecordName'] = Lang::get($this->getConfig('name', 'backend::lang.model.name'));
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -124,9 +135,8 @@ class FormController extends ControllerBehavior
|
|||
$this->context = strlen($context) ? $context : $this->getConfig('create[context]', 'create');
|
||||
$this->controller->pageTitle = $this->controller->pageTitle ?: $this->getLang('create[title]', 'backend::lang.form.create_title');
|
||||
$model = $this->controller->formCreateModelObject();
|
||||
$this->initForm($model);
|
||||
|
||||
$this->controller->vars['formModel'] = $model;
|
||||
$this->initForm($model);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
$this->controller->handleError($ex);
|
||||
|
|
@ -176,9 +186,8 @@ class FormController extends ControllerBehavior
|
|||
$this->context = strlen($context) ? $context : $this->getConfig('update[context]', 'update');
|
||||
$this->controller->pageTitle = $this->controller->pageTitle ?: $this->getLang('update[title]', 'backend::lang.form.update_title');
|
||||
$model = $this->controller->formFindModelObject($recordId);
|
||||
$this->initForm($model);
|
||||
|
||||
$this->controller->vars['formModel'] = $model;
|
||||
$this->initForm($model);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
$this->controller->handleError($ex);
|
||||
|
|
@ -250,9 +259,8 @@ class FormController extends ControllerBehavior
|
|||
$this->context = strlen($context) ? $context : $this->getConfig('preview[context]', 'preview');
|
||||
$this->controller->pageTitle = $this->controller->pageTitle ?: $this->getLang('preview[title]', 'backend::lang.form.preview_title');
|
||||
$model = $this->controller->formFindModelObject($recordId);
|
||||
$this->initForm($model);
|
||||
|
||||
$this->controller->vars['formModel'] = $model;
|
||||
$this->initForm($model);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
$this->controller->handleError($ex);
|
||||
|
|
@ -353,10 +361,10 @@ class FormController extends ControllerBehavior
|
|||
{
|
||||
$name = $this->getConfig($name, $default);
|
||||
$vars = [
|
||||
'name' => Lang::get($this->getConfig('name', trans('backend::lang.model.name')))
|
||||
'name' => Lang::get($this->getConfig('name', 'backend::lang.model.name'))
|
||||
];
|
||||
$vars = array_merge($vars, $extras);
|
||||
return trans($name, $vars);
|
||||
return Lang::get($name, $vars);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -163,8 +163,8 @@ return [
|
|||
'select_placeholder' => 'Bitte auswählen',
|
||||
'insert_row' => 'Reihe einfügen',
|
||||
'delete_row' => 'Reihe löschen',
|
||||
'concurrency-file-changed-title' => 'Datei wurde geändert',
|
||||
'concurrency-file-changed-description' => 'Die Datei, welche Sie bearbeiten, wurde auf von einem anderen Benutzer geändert. Sie können die Datei entweder erneut laden, wodurch Ihre Änderungen verloren gehen oder Sie überschreiben die Datei auf dem Server',
|
||||
'concurrency_file_changed_title' => 'Datei wurde geändert',
|
||||
'concurrency_file_changed_description' => 'Die Datei, welche Sie bearbeiten, wurde auf von einem anderen Benutzer geändert. Sie können die Datei entweder erneut laden, wodurch Ihre Änderungen verloren gehen oder Sie überschreiben die Datei auf dem Server',
|
||||
'reload' => 'Erneut laden',
|
||||
],
|
||||
'relation' => [
|
||||
|
|
|
|||
|
|
@ -139,14 +139,18 @@ return [
|
|||
'missing_model' => 'Form behavior used in :class does not have a model defined.',
|
||||
'missing_definition' => "Form behavior does not contain a field for ':field'.",
|
||||
'not_found' => 'Form record with an ID of :id could not be found.',
|
||||
'action_confirm' => "Are you sure?",
|
||||
'create' => 'Create',
|
||||
'create_and_close' => 'Create and close',
|
||||
'creating' => 'Creating...',
|
||||
'creating_name' => 'Creating :name...',
|
||||
'save' => 'Save',
|
||||
'save_and_close' => 'Save and close',
|
||||
'saving' => 'Saving...',
|
||||
'saving_name' => 'Saving :name...',
|
||||
'delete' => 'Delete',
|
||||
'deleting' => 'Deleting...',
|
||||
'deleting_name' => 'Deleting :name...',
|
||||
'undefined_tab' => 'Misc',
|
||||
'field_off' => 'Off',
|
||||
'field_on' => 'On',
|
||||
|
|
@ -154,6 +158,8 @@ return [
|
|||
'apply' => 'Apply',
|
||||
'cancel' => 'Cancel',
|
||||
'close' => 'Close',
|
||||
'confirm' => 'Confirm',
|
||||
'reload' => 'Reload',
|
||||
'ok' => 'OK',
|
||||
'or' => 'or',
|
||||
'confirm_tab_close' => 'Do you really want to close the tab? Unsaved changes will be lost.',
|
||||
|
|
@ -165,9 +171,8 @@ return [
|
|||
'select_placeholder' => 'please select',
|
||||
'insert_row' => 'Insert Row',
|
||||
'delete_row' => 'Delete Row',
|
||||
'concurrency-file-changed-title' => 'File was changed',
|
||||
'concurrency-file-changed-description' => 'The file you\'re editing has been changed on disk by another user. You can either reload the file and lose your changes or override the file on the disk.',
|
||||
'reload' => 'Reload',
|
||||
'concurrency_file_changed_title' => "File was changed",
|
||||
'concurrency_file_changed_description' => "The file you're editing has been changed on disk by another user. You can either reload the file and lose your changes or override the file on the disk.",
|
||||
],
|
||||
'relation' => [
|
||||
'missing_definition' => "Relation behavior does not contain a definition for ':field'.",
|
||||
|
|
|
|||
|
|
@ -165,8 +165,8 @@ return [
|
|||
'select_placeholder' => 'لطفا انتخاب نمایید',
|
||||
'insert_row' => 'افزودن سطر',
|
||||
'delete_row' => 'حذف سطر',
|
||||
'concurrency-file-changed-title' => 'فایل تغییر کرد',
|
||||
'concurrency-file-changed-description' => 'فایلی که شما ویرایش کردید توسط کاربر دیگری تغییر یافته و ذخیره شده است. شما میتوانید فایل را مجددا بارگذاری نمایید و تغییراتی که اعمال کرده اید را از دست بدهید و یا تغییرات اعمال شده توسط آن کاربر را بین برده و فایل را بازنویسی نمایید.',
|
||||
'concurrency_file_changed_title' => 'فایل تغییر کرد',
|
||||
'concurrency_file_changed_description' => 'فایلی که شما ویرایش کردید توسط کاربر دیگری تغییر یافته و ذخیره شده است. شما میتوانید فایل را مجددا بارگذاری نمایید و تغییراتی که اعمال کرده اید را از دست بدهید و یا تغییرات اعمال شده توسط آن کاربر را بین برده و فایل را بازنویسی نمایید.',
|
||||
'reload' => 'بارگذاری مجدد',
|
||||
],
|
||||
'relation' => [
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?php namespace Backend\Traits;
|
||||
|
||||
use Request;
|
||||
use System\Classes\SystemException;
|
||||
use System\Classes\ApplicationException;
|
||||
use Request;
|
||||
|
||||
/**
|
||||
* Inspectable Container Trait
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ class Form extends WidgetBase
|
|||
}
|
||||
|
||||
/**
|
||||
* Prepares the list data
|
||||
* Prepares the form data
|
||||
*/
|
||||
protected function prepareVars()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,11 +45,18 @@ class ComponentHelpers
|
|||
/*
|
||||
* Translate human values
|
||||
*/
|
||||
$translate = ['title', 'description'];
|
||||
$translate = ['title', 'description', 'options'];
|
||||
foreach ($property as $name => $value) {
|
||||
if (!in_array($name, $translate)) continue;
|
||||
if (!in_array($name, $translate))
|
||||
continue;
|
||||
|
||||
if (is_array($value)) {
|
||||
array_walk($property[$name], function(&$_value, $key) { $_value = Lang::get($_value); });
|
||||
}
|
||||
else {
|
||||
$property[$name] = Lang::get($value);
|
||||
}
|
||||
}
|
||||
|
||||
$result[] = $property;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,12 +44,16 @@ class Components extends FormWidgetBase
|
|||
$componentObj->alias = $alias;
|
||||
$componentObj->pluginIcon = 'icon-puzzle-piece';
|
||||
|
||||
/*
|
||||
* Look up the plugin hosting this component
|
||||
*/
|
||||
$plugin = $manager->findComponentPlugin($componentObj);
|
||||
if ($plugin) {
|
||||
$pluginDetails = $plugin->pluginDetails();
|
||||
if (isset($pluginDetails['icon']))
|
||||
$componentObj->pluginIcon = $pluginDetails['icon'];
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
$componentObj = new UnknownComponent(null, $properties, $ex->getMessage());
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
<span class="description"><?= $description ?></span>
|
||||
<span class="alias oc-icon-code"><?= e($component->alias) ?></span>
|
||||
<input type="hidden" name="component_properties[]" data-inspector-values value="<?= e($this->getComponentPropertyValues($component)) ?>" />
|
||||
<input type="hidden" name="component_names[]" value="<?= e($component->name) ?>"></input>
|
||||
<input type="hidden" name="component_aliases[]" value="<?= e($component->alias) ?>"></input>
|
||||
<input type="hidden" name="component_names[]" value="<?= e($component->name) ?>" />
|
||||
<input type="hidden" name="component_aliases[]" value="<?= e($component->alias) ?>" />
|
||||
<a href="#" class="remove">×</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,18 +1,17 @@
|
|||
<div class="control-componentlist">
|
||||
<?php
|
||||
foreach ($components as $component) {
|
||||
if ($component->isHidden)
|
||||
echo $this->makePartial('component', ['component'=>$component]);
|
||||
}
|
||||
?>
|
||||
<?php foreach ($components as $component): ?>
|
||||
<?php if ($component->isHidden): ?>
|
||||
<?= $this->makePartial('component', ['component' => $component]) ?>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
|
||||
<div class="components" data-control="toolbar">
|
||||
<div class="layout">
|
||||
<?php
|
||||
foreach ($components as $component) {
|
||||
if (!$component->isHidden)
|
||||
echo $this->makePartial('component', ['component'=>$component]);
|
||||
}
|
||||
?>
|
||||
<?php foreach ($components as $component): ?>
|
||||
<?php if (!$component->isHidden): ?>
|
||||
<?= $this->makePartial('component', ['component' => $component]) ?>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue