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