Skip to content

A free open source IT asset/license management system

move translations in to EditorSections trait

Godfrey M6dc7ffa77905
diff --git a/app/Models/Labels/CustomLabels/Concerns/HasCustomLabelEditorSections.php b/app/Models/Labels/CustomLabels/Concerns/HasCustomLabelEditorSections.php
index 8b7c043a28..26c2aa3c29 100644
--- a/app/Models/Labels/CustomLabels/Concerns/HasCustomLabelEditorSections.php
+++ b/app/Models/Labels/CustomLabels/Concerns/HasCustomLabelEditorSections.php
@@ -17,111 +17,166 @@ trait HasCustomLabelEditorSections
{
return [
'supports' => [
- 'label' => 'admin/labels/general.sections.supports',
+ 'label' => trans('admin/labels/general.sections.supports'),
'column_span' => 2,
'display' => 'inline',
'fields' => [
- 'fields' => ['type' => 'number'],
- 'asset_tag' => ['type' => 'checkbox'],
- 'barcode_1d' => ['type' => 'checkbox'],
- 'barcode_2d' => ['type' => 'checkbox'],
- 'logo' => ['type' => 'checkbox'],
- 'title' => ['type' => 'checkbox'],
+ 'fields' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.fields'),
+ ],
+ 'asset_tag' => [
+ 'type' => 'checkbox',
+ 'label' => trans('admin/labels/general.fields.asset_tag'),
+ ],
+ 'barcode_1d' => [
+ 'type' => 'checkbox',
+ 'label' => trans('admin/labels/general.fields.barcode_1d'),
+ ],
+ 'barcode_2d' => [
+ 'type' => 'checkbox',
+ 'label' => trans('admin/labels/general.fields.barcode_2d'),
+ ],
+ 'logo' => [
+ 'type' => 'checkbox',
+ 'label' => trans('admin/labels/general.fields.logo'),
+ ],
+ 'title' => [
+ 'type' => 'checkbox',
+ 'label' => trans('admin/labels/general.fields.title'),
+ ],
],
],
'content' => [
- 'label' => 'admin/labels/general.sections.content',
+ 'label' => trans('admin/labels/general.sections.content'),
'column_span' => 2,
'groups' => [
'barcode_1d' => [
- 'label' => 'admin/labels/general.groups.barcode_1d',
+ 'label' => trans('admin/labels/general.groups.barcode_1d'),
'toggle' => 'supports.barcode_1d',
'fields' => [
- 'barcode_size' => ['type' => 'number'],
- 'barcode_margin' => ['type' => 'number'],
+ 'barcode_size' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.barcode_size'),
+ ],
+ 'barcode_margin' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.barcode_margin'),
+ ],
'barcode1D_v_align' => [
'type' => 'select',
+ 'label' => trans('admin/labels/general.fields.barcode1D_v_align'),
'options' => [
- 'T' => 'admin/labels/general.options.top',
- 'M' => 'admin/labels/general.options.middle',
- 'B' => 'admin/labels/general.options.bottom',
+ 'T' => trans('admin/labels/general.options.top'),
+ 'M' => trans('admin/labels/general.options.middle'),
+ 'B' => trans('admin/labels/general.options.bottom'),
],
],
],
],
'barcode_2d' => [
- 'label' => 'admin/labels/general.groups.barcode_2d',
+ 'label' => trans('admin/labels/general.groups.barcode_2d'),
'toggle' => 'supports.barcode_2d',
'fields' => [
- 'barcode_2d_size' => ['type' => 'number'],
+ 'barcode_2d_size' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.barcode_2d_size'),
+ ],
'barcode2D_h_align' => [
'type' => 'select',
+ 'label' => trans('admin/labels/general.fields.barcode2D_h_align'),
'options' => [
- 'L' => 'admin/labels/general.options.left',
- 'C' => 'admin/labels/general.options.center',
- 'R' => 'admin/labels/general.options.right',
+ 'L' => trans('admin/labels/general.options.left'),
+ 'C' => trans('admin/labels/general.options.center'),
+ 'R' => trans('admin/labels/general.options.right'),
],
],
'barcode2D_v_align' => [
'type' => 'select',
+ 'label' => trans('admin/labels/general.fields.barcode2D_v_align'),
'options' => [
- 'T' => 'admin/labels/general.options.top',
- 'M' => 'admin/labels/general.options.middle',
- 'B' => 'admin/labels/general.options.bottom',
+ 'T' => trans('admin/labels/general.options.top'),
+ 'M' => trans('admin/labels/general.options.middle'),
+ 'B' => trans('admin/labels/general.options.bottom'),
],
],
],
],
'tag' => [
- 'label' => 'admin/labels/general.groups.tag',
+ 'label' => trans('admin/labels/general.groups.tag'),
'toggle' => 'supports.asset_tag',
'fields' => [
- 'tag_font' => ['type' => 'select',
+ 'tag_font' => [
+ 'type' => 'select',
+ 'label' => trans('admin/labels/general.fields.tag_font'),
'options' => [
- 'freemono' => 'admin/labels/general.options.freemono',
- 'freesans' => 'admin/labels/general.options.freesans',
- 'dejavusans' => 'admin/labels/general.options.dejavusans',
+ 'freemono' => trans('admin/labels/general.options.freemono'),
+ 'freesans' => trans('admin/labels/general.options.freesans'),
+ 'dejavusans' => trans('admin/labels/general.options.dejavusans'),
],
],
- 'tag_font_size' => ['type' => 'number'],
+ 'tag_font_size' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.tag_font_size'),
+ ],
'tag_alignment' => [
'type' => 'select',
+ 'label' => trans('admin/labels/general.fields.tag_alignment'),
'options' => [
- 'L' => 'admin/labels/general.options.left',
- 'C' => 'admin/labels/general.options.center',
- 'R' => 'admin/labels/general.options.right',
+ 'L' => trans('admin/labels/general.options.left'),
+ 'C' => trans('admin/labels/general.options.center'),
+ 'R' => trans('admin/labels/general.options.right'),
],
],
- 'tag_offset_x' => ['type' => 'number'],
- 'tag_offset_y' => ['type' => 'number'],
+ 'tag_offset_x' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.tag_offset_x'),
+ ],
+ 'tag_offset_y' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.tag_offset_y'),
+ ],
],
],
'title' => [
- 'label' => 'admin/labels/general.groups.title',
+ 'label' => trans('admin/labels/general.groups.title'),
'toggle' => 'supports.title',
'fields' => array_filter([
'title_font' => [
'type' => 'select',
+ 'label' => trans('admin/labels/general.fields.title_font'),
'options' => [
- 'freemono' => 'admin/labels/general.options.freemono',
- 'freesans' => 'admin/labels/general.options.freesans',
- 'dejavusans' => 'admin/labels/general.options.dejavusans',
+ 'freemono' => trans('admin/labels/general.options.freemono'),
+ 'freesans' => trans('admin/labels/general.options.freesans'),
+ 'dejavusans' => trans('admin/labels/general.options.dejavusans'),
],
],
- 'title_font_size' => ['type' => 'number'],
- 'title_margin' => ['type' => 'number'],
- 'title_offset_x' => ['type' => 'number'],
+ 'title_font_size' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.title_font_size'),
+ ],
+
+ 'title_margin' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.title_margin'),
+ ],
+
+ 'title_offset_x' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.title_offset_x'),
+ ],
'title_position' => !$this->isTapeLabel()
? [
'type' => 'select',
+ 'label' => trans('admin/labels/general.fields.title_position'),
'options' => [
- 'inline' => 'admin/labels/general.options.inline',
- 'top' => 'admin/labels/general.options.top',
+ 'inline' => trans('admin/labels/general.options.inline'),
+ 'top' => trans('admin/labels/general.options.top'),
],
]
: null,
@@ -129,49 +184,72 @@ trait HasCustomLabelEditorSections
],
'field_labels' => [
- 'label' => 'admin/labels/general.groups.field_labels',
+ 'label' => trans('admin/labels/general.groups.field_labels'),
'toggle' => 'supports.fields',
'fields' => [
- 'field_label_font' => ['type' => 'select',
+ 'field_label_font' => [
+ 'type' => 'select',
+ 'label' => trans('admin/labels/general.fields.field_label_font'),
'options' => [
- 'freemono' => 'admin/labels/general.options.freemono',
- 'freesans' => 'admin/labels/general.options.freesans',
- 'dejavusans' => 'admin/labels/general.options.dejavusans',
+ 'freemono' => trans('admin/labels/general.options.freemono'),
+ 'freesans' => trans('admin/labels/general.options.freesans'),
+ 'dejavusans' => trans('admin/labels/general.options.dejavusans'),
],
],
- 'field_label_font_size' => ['type' => 'number'],
- 'field_label_margin' => ['type' => 'number'],
+ 'field_label_font_size' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.field_label_font_size'),
+ ],
+ 'field_label_margin' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.field_label_margin'),
+ ],
],
],
'field_values' => [
- 'label' => 'admin/labels/general.groups.field_values',
+ 'label' => trans('admin/labels/general.groups.field_values'),
'toggle' => 'supports.fields',
'fields' => [
- 'field_value_font' => ['type' => 'select',
+ 'field_value_font' => [
+ 'type' => 'select',
+ 'label' => trans('admin/labels/general.fields.field_value_font'),
'options' => [
- 'freemono' => 'admin/labels/general.options.freemono',
- 'freesans' => 'admin/labels/general.options.freesans',
- 'dejavusans' => 'admin/labels/general.options.dejavusans',
+ 'freemono' => trans('admin/labels/general.options.freemono'),
+ 'freesans' => trans('admin/labels/general.options.freesans'),
+ 'dejavusans' => trans('admin/labels/general.options.dejavusans'),
],
],
- 'field_value_font_size' => ['type' => 'number'],
- 'field_value_margin' => ['type' => 'number'],
+ 'field_value_font_size' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.field_value_font_size'),
+ ],
+ 'field_value_margin' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.field_value_margin'),
+ ],
],
],
'logo' => [
- 'label' => 'admin/labels/general.groups.logo',
+ 'label' => trans('admin/labels/general.groups.logo'),
'toggle' => 'supports.logo',
'fields' => [
- 'logo_max_width' => ['type' => 'number'],
- 'logo_margin' => ['type' => 'number'],
+ 'logo_max_width' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.logo_max_width'),
+ ],
+ 'logo_margin' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.logo_margin'),
+ ],
'logo_h_align' => [
'type' => 'select',
+ 'label' => trans('admin/labels/general.fields.logo_h_align'),
'options' => [
- 'L' => 'admin/labels/general.options.left',
- 'C' => 'admin/labels/general.options.center',
- 'R' => 'admin/labels/general.options.right',
+ 'L' => trans('admin/labels/general.options.left'),
+ 'C' => trans('admin/labels/general.options.center'),
+ 'R' => trans('admin/labels/general.options.right'),
],
],
],
@@ -201,44 +279,95 @@ trait HasCustomLabelEditorSections
{
return [
'layout' => [
- 'label' => 'admin/labels/general.sections.layout',
+ 'label' => trans('admin/labels/general.sections.layout'),
'column_span' => 2,
'groups' => [
'page' => [
- 'label' => 'admin/labels/general.sections.page',
+ 'label' => trans('admin/labels/general.sections.page'),
'section_key' => 'page',
'fields' => [
- 'width' => ['type' => 'number'],
- 'height' => ['type' => 'number'],
- 'margin_top' => ['type' => 'number'],
- 'margin_right' => ['type' => 'number'],
- 'margin_bottom' => ['type' => 'number'],
- 'margin_left' => ['type' => 'number'],
+ 'width' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.width'),
+ ],
+ 'height' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.height'),
+ ],
+ 'margin_top' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.margin_top'),
+ ],
+ 'margin_right' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.margin_right'),
+ ],
+ 'margin_bottom' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.margin_bottom'),
+ ],
+ 'margin_left' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.margin_left'),
+ ],
],
],
'grid' => [
- 'label' => 'admin/labels/general.sections.grid',
+ 'label' => trans('admin/labels/general.sections.grid'),
'section_key' => 'grid',
'fields' => [
- 'columns' => ['type' => 'number'],
- 'rows' => ['type' => 'number'],
- 'column_spacing' => ['type' => 'number'],
- 'row_spacing' => ['type' => 'number'],
+ 'columns' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.columns'),
+ ],
+ 'rows' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.rows'),
+ ],
+ 'column_spacing' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.column_spacing'),
+ ],
+ 'row_spacing' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.row_spacing'),
+ ],
],
],
'label' => [
- 'label' => 'admin/labels/general.sections.label',
+ 'label' => trans('admin/labels/general.sections.label'),
'section_key' => 'label',
'fields' => [
- 'width' => ['type' => 'number'],
- 'height' => ['type' => 'number'],
- 'border' => ['type' => 'number'],
- 'padding_top' => ['type' => 'number'],
- 'padding_right' => ['type' => 'number'],
- 'padding_bottom' => ['type' => 'number'],
- 'padding_left' => ['type' => 'number'],
+ 'width' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.width'),
+ ],
+ 'height' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.height'),
+ ],
+ 'border' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.border'),
+ ],
+ 'padding_top' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.padding_top'),
+ ],
+ 'padding_right' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.padding_right'),
+ ],
+ 'padding_bottom' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.padding_bottom'),
+ ],
+ 'padding_left' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.padding_left'),
+ ],
],
],
],
@@ -250,16 +379,25 @@ trait HasCustomLabelEditorSections
{
return [
'layout' => [
- 'label' => 'admin/labels/general.sections.layout',
+ 'label' => trans('admin/labels/general.sections.layout'),
'column_span' => 2,
'groups' => [
'label' => [
- 'label' => 'admin/labels/general.sections.label',
+ 'label' => trans('admin/labels/general.sections.label'),
'section_key' => 'dimensions',
'fields' => [
- 'width' => ['type' => 'number'],
- 'height' => ['type' => 'number'],
- 'label_gap' => ['type' => 'number'],
+ 'width' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.width'),
+ ],
+ 'height' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.height'),
+ ],
+ 'label_gap' => [
+ 'type' => 'number',
+ 'label' => trans('admin/labels/general.fields.label_gap'),
+ ],
],
],
],
diff --git a/resources/views/partials/label-editor-field.blade.php b/resources/views/partials/label-editor-field.blade.php
index 2162790403..a77d8444f7 100644
--- a/resources/views/partials/label-editor-field.blade.php
+++ b/resources/views/partials/label-editor-field.blade.php
@@ -5,7 +5,7 @@
<div class="form-group">
<label class="col-md-4 control-label">
- {{ trans("admin/labels/general.fields.{$fieldKey}") }}
+ {{ $field['label'] }}
</label>
<div class="col-md-4">
@@ -18,6 +18,7 @@
value="1"
@checked((bool) $value)
>
+
@elseif ($field['type'] === 'select')
<select name="{{ $name }}" class="form-control">
@foreach ($field['options'] as $optionValue => $optionLabel)
@@ -25,10 +26,11 @@
value="{{ $optionValue }}"
@selected($value == $optionValue)
>
- {{ trans($optionLabel) }}
+ {{ $optionLabel }}
</option>
@endforeach
</select>
+
@else
<input
type="{{ $field['type'] }}"
diff --git a/resources/views/partials/label-editor-section.blade.php b/resources/views/partials/label-editor-section.blade.php
index a5b74e8d62..05ce56a8af 100644
--- a/resources/views/partials/label-editor-section.blade.php
+++ b/resources/views/partials/label-editor-section.blade.php
@@ -1,7 +1,7 @@
<div class="box box-default label-config-panel">
<div class="box-header with-border">
<x-form.legend>
- {{ trans($section['label']) }}
+ {{ $section['label'] }}
</x-form.legend>
</div>
@@ -26,7 +26,7 @@
@checked((bool) $value)
>
- {{ trans("admin/labels/general.fields.{$fieldKey}") }}
+ {{ $field['label'] }}
@elseif ($field['type'] === 'number')
@@ -40,13 +40,13 @@
>
<label for="{{ $name }}">
- {{ trans("admin/labels/general.fields.{$fieldKey}") }}
+ {{ $field['label'] }}
</label>
</div>
@else
- {{ trans("admin/labels/general.fields.{$fieldKey}") }}
+ {{ $field['label'] }}
<input
type="{{ $field['type'] }}"
@@ -60,6 +60,7 @@
</div>
@endforeach
</div>
+
@elseif (isset($section['groups']))
<div class="label-content-groups">
@foreach ($section['groups'] as $groupKey => $group)
@@ -80,7 +81,7 @@
@endif
>
<div class="panel-heading">
- <strong>{{ trans($group['label']) }}</strong>
+ <strong>{{ $group['label'] }}</strong>
</div>
<div class="panel-body">
@@ -96,6 +97,7 @@
</div>
@endforeach
</div>
+
@else
@foreach ($section['fields'] as $fieldKey => $field)
@include('partials.label-editor-field', [