Completed Multi Lang Support & Refactoring Pending
This commit is contained in:
parent
dace5f9ecb
commit
03eeafc5de
|
|
@ -64,8 +64,8 @@
|
|||
$field['options'] = '';
|
||||
}
|
||||
|
||||
$selectedOption = core()->getConfigData($name) ?? '';
|
||||
$dependSelectedOption = core()->getConfigData(implode('.', [$firstField, $secondField, $thirdField, $dependField])) ?? '';
|
||||
$selectedOption = core()->getConfigData($name, $channel, $locale) ?? '';
|
||||
$dependSelectedOption = core()->getConfigData(implode('.', [$firstField, $secondField, $thirdField, $dependField]), $channel, $locale) ?? '';
|
||||
?>
|
||||
|
||||
@if (strpos($field['validation'], 'required_if') !== false)
|
||||
|
|
@ -110,31 +110,31 @@
|
|||
|
||||
@if ($field['type'] == 'text')
|
||||
|
||||
<input type="text" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="{{ old($name) ?: (core()->getConfigData($name) ? core()->getConfigData($name) : (isset($field['default_value']) ? $field['default_value'] : '')) }}" data-vv-as=""{{ trans($field['title']) }}"">
|
||||
<input type="text" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="{{ old($name) ?: (core()->getConfigData($name, $channel, $locale) ? core()->getConfigData($name, $channel, $locale) : (isset($field['default_value']) ? $field['default_value'] : '')) }}" data-vv-as=""{{ trans($field['title']) }}"">
|
||||
|
||||
@elseif ($field['type'] == 'password')
|
||||
|
||||
<input type="password" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="{{ old($name) ?: core()->getConfigData($name) }}" data-vv-as=""{{ trans($field['title']) }}"">
|
||||
<input type="password" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="{{ old($name) ?: core()->getConfigData($name, $channel, $locale) }}" data-vv-as=""{{ trans($field['title']) }}"">
|
||||
|
||||
@elseif ($field['type'] == 'number')
|
||||
|
||||
<input type="number" min="0" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="{{ old($name) ?: core()->getConfigData($name) }}" data-vv-as=""{{ trans($field['title']) }}"">
|
||||
<input type="number" min="0" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="{{ old($name) ?: core()->getConfigData($name, $channel, $locale) }}" data-vv-as=""{{ trans($field['title']) }}"">
|
||||
|
||||
@elseif ($field['type'] == 'color')
|
||||
|
||||
<input type="color" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="{{ old($name) ?: core()->getConfigData($name) }}" data-vv-as=""{{ trans($field['title']) }}"">
|
||||
<input type="color" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="{{ old($name) ?: core()->getConfigData($name, $channel, $locale) }}" data-vv-as=""{{ trans($field['title']) }}"">
|
||||
|
||||
|
||||
@elseif ($field['type'] == 'textarea')
|
||||
|
||||
<textarea v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" data-vv-as=""{{ trans($field['title']) }}"">{{ old($name) ?: core()->getConfigData($name) ?: (isset($field['default_value']) ? $field['default_value'] : '') }}</textarea>
|
||||
<textarea v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" data-vv-as=""{{ trans($field['title']) }}"">{{ old($name) ?: core()->getConfigData($name, $channel, $locale) ?: (isset($field['default_value']) ? $field['default_value'] : '') }}</textarea>
|
||||
|
||||
@elseif ($field['type'] == 'select')
|
||||
|
||||
<select v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" data-vv-as=""{{ trans($field['title']) }}"" >
|
||||
|
||||
<?php
|
||||
$selectedOption = core()->getConfigData($name) ?? '';
|
||||
$selectedOption = core()->getConfigData($name, $channel, $locale) ?? '';
|
||||
?>
|
||||
|
||||
@if (isset($field['repository']))
|
||||
|
|
@ -172,7 +172,7 @@
|
|||
<select v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}][]" data-vv-as=""{{ trans($field['title']) }}"" multiple>
|
||||
|
||||
<?php
|
||||
$selectedOption = core()->getConfigData($name) ?? '';
|
||||
$selectedOption = core()->getConfigData($name, $channel, $locale) ?? '';
|
||||
?>
|
||||
|
||||
@if (isset($field['repository']))
|
||||
|
|
@ -208,7 +208,7 @@
|
|||
@elseif ($field['type'] == 'country')
|
||||
|
||||
<?php
|
||||
$countryCode = core()->getConfigData($name) ?? '';
|
||||
$countryCode = core()->getConfigData($name, $channel, $locale) ?? '';
|
||||
?>
|
||||
|
||||
<country
|
||||
|
|
@ -220,7 +220,7 @@
|
|||
@elseif ($field['type'] == 'state')
|
||||
|
||||
<?php
|
||||
$stateCode = core()->getConfigData($name) ?? '';
|
||||
$stateCode = core()->getConfigData($name, $channel, $locale) ?? '';
|
||||
?>
|
||||
|
||||
<state
|
||||
|
|
@ -231,7 +231,7 @@
|
|||
|
||||
@elseif ($field['type'] == 'boolean')
|
||||
|
||||
<?php $selectedOption = core()->getConfigData($name) ?? (isset($field['default_value']) ? $field['default_value'] : ''); ?>
|
||||
<?php $selectedOption = core()->getConfigData($name, $channel, $locale) ?? (isset($field['default_value']) ? $field['default_value'] : ''); ?>
|
||||
|
||||
<label class="switch">
|
||||
<input type="hidden" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="0" />
|
||||
|
|
@ -242,8 +242,8 @@
|
|||
@elseif ($field['type'] == 'image')
|
||||
|
||||
<?php
|
||||
$src = Storage::url(core()->getConfigData($name));
|
||||
$result = core()->getConfigData($name);
|
||||
$src = Storage::url(core()->getConfigData($name, $channel, $locale));
|
||||
$result = core()->getConfigData($name, $channel, $locale);
|
||||
?>
|
||||
|
||||
@if ($result)
|
||||
|
|
@ -252,7 +252,7 @@
|
|||
</a>
|
||||
@endif
|
||||
|
||||
<input type="file" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="{{ old($name) ?: core()->getConfigData($name) }}" data-vv-as=""{{ trans($field['title']) }}"" style="padding-top: 5px;">
|
||||
<input type="file" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="{{ old($name) ?: core()->getConfigData($name, $channel, $locale) }}" data-vv-as=""{{ trans($field['title']) }}"" style="padding-top: 5px;">
|
||||
|
||||
@if ($result)
|
||||
<div class="control-group" style="margin-top: 5px;">
|
||||
|
|
@ -268,7 +268,7 @@
|
|||
@elseif ($field['type'] == 'file')
|
||||
|
||||
<?php
|
||||
$result = core()->getConfigData($name);
|
||||
$result = core()->getConfigData($name, $channel, $locale);
|
||||
$src = explode("/", $result);
|
||||
$path = end($src);
|
||||
?>
|
||||
|
|
@ -279,7 +279,7 @@
|
|||
</a>
|
||||
@endif
|
||||
|
||||
<input type="file" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="{{ old($name) ?: core()->getConfigData($name) }}" data-vv-as=""{{ trans($field['title']) }}"" style="padding-top: 5px;">
|
||||
<input type="file" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="{{ old($name) ?: core()->getConfigData($name, $channel, $locale) }}" data-vv-as=""{{ trans($field['title']) }}"" style="padding-top: 5px;">
|
||||
|
||||
@if ($result)
|
||||
<div class="control-group" style="margin-top: 5px;">
|
||||
|
|
|
|||
|
|
@ -7,14 +7,13 @@
|
|||
@section('content')
|
||||
<div class="content">
|
||||
@php
|
||||
$locale = request()->get('locale') ?: app()->getLocale();
|
||||
$channel = request()->get('channel') ?: core()->getDefaultChannelCode();
|
||||
/* getting channel and locales */
|
||||
$mainConfigurations = core()->getChannelCodeAndLocaleCode();
|
||||
|
||||
$channelLocales = app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales;
|
||||
|
||||
if (! $channelLocales->contains('code', $locale)) {
|
||||
$locale = config('app.fallback_locale');
|
||||
}
|
||||
/* assigning */
|
||||
$locale = $mainConfigurations['localeCode'];
|
||||
$channel = $mainConfigurations['channelCode'];
|
||||
$channelLocales = $mainConfigurations['channelLocales'];
|
||||
@endphp
|
||||
|
||||
<form method="POST" action="" @submit.prevent="onSubmit" enctype="multipart/form-data">
|
||||
|
|
|
|||
|
|
@ -41,8 +41,12 @@ class ConfigurationController extends Controller
|
|||
$this->velocityHelper = app('Webkul\Velocity\Helpers\Helper');
|
||||
$this->velocityMetaDataRepository = $velocityMetadataRepository;
|
||||
|
||||
$this->locale = request()->get('locale') ?: app()->getLocale();
|
||||
$this->channel = request()->get('channel') ?: 'default';
|
||||
/* getting channel and locales */
|
||||
$mainConfigurations = core()->getChannelCodeAndLocaleCode();
|
||||
|
||||
/* assigning */
|
||||
$this->locale = $mainConfigurations['localeCode'];
|
||||
$this->channel = $mainConfigurations['channelCode'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -52,8 +56,6 @@ class ConfigurationController extends Controller
|
|||
*/
|
||||
public function renderMetaData()
|
||||
{
|
||||
$this->locale = request()->get('locale') ? request()->get('locale') : app()->getLocale();
|
||||
|
||||
$velocityMetaData = $this->velocityHelper->getVelocityMetaData($this->locale, $this->channel, false);
|
||||
|
||||
if (! $velocityMetaData) {
|
||||
|
|
|
|||
|
|
@ -5,14 +5,13 @@
|
|||
@stop
|
||||
|
||||
@php
|
||||
$locale = request()->get('locale') ?: app()->getLocale();
|
||||
$channel = request()->get('channel') ?: core()->getDefaultChannelCode();
|
||||
/* getting channel and locales */
|
||||
$mainConfigurations = core()->getChannelCodeAndLocaleCode();
|
||||
|
||||
$channelLocales = app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales;
|
||||
|
||||
if (! $channelLocales->contains('code', $locale)) {
|
||||
$locale = config('app.fallback_locale');
|
||||
}
|
||||
/* assigning */
|
||||
$locale = $mainConfigurations['localeCode'];
|
||||
$channel = $mainConfigurations['channelCode'];
|
||||
$channelLocales = $mainConfigurations['channelLocales'];
|
||||
@endphp
|
||||
|
||||
@section('content')
|
||||
|
|
|
|||
Loading…
Reference in New Issue