Added locale option to config

This commit is contained in:
Julian Prieber 2023-06-11 19:05:36 +02:00
parent 193fe84dcc
commit 1fbf124ebe
4 changed files with 51 additions and 2 deletions

2
.env
View File

@ -1,3 +1,5 @@
LOCALE=en
#Email verification=Changes if users have to verify their email after registration. #Email verification=Changes if users have to verify their email after registration.
#=REGISTER_AUTH either auth or verified. If auth is selected, no verification is required. Default is verified. #=REGISTER_AUTH either auth or verified. If auth is selected, no verification is required. Default is verified.
REGISTER_AUTH=auth REGISTER_AUTH=auth

View File

@ -290,6 +290,7 @@ return [
'SMTP' => 'SMTP+', 'SMTP' => 'SMTP+',
'Footer links' => 'Footer links+', 'Footer links' => 'Footer links+',
'Debug' => 'Debug+', 'Debug' => 'Debug+',
'Language' => 'Language+',
'default' => 'default+', 'default' => 'default+',
'Apply' => 'Apply+', 'Apply' => 'Apply+',
@ -458,6 +459,8 @@ return [
'HOME_URL.description' => 'Set a user page as the home page. This will move the previous home page to example.com/home.+', 'HOME_URL.description' => 'Set a user page as the home page. This will move the previous home page to example.com/home.+',
'MAINTENANCE_MODE.title' => 'Enable Maintenance Mode+', 'MAINTENANCE_MODE.title' => 'Enable Maintenance Mode+',
'MAINTENANCE_MODE.description' => 'Displays a maintenance message on all public pages. This will disable the login pages.+', 'MAINTENANCE_MODE.description' => 'Displays a maintenance message on all public pages. This will disable the login pages.+',
'LOCALE.title' => 'App locale+',
'LOCALE.description' => 'Change the language of your application+',
'' => '+', '' => '+',

View File

@ -414,8 +414,8 @@ document.getElementById("MAINTENANCE_MODE-form").addEventListener("change", func
<div class="form-group col-lg-8"> <div class="form-group col-lg-8">
<input value="text" name="type" style="display:none;" type="text" class="form-control form-control-lg" required> <input value="text" name="type" style="display:none;" type="text" class="form-control form-control-lg" required>
<input value="HOME_FOOTER_LINK" name="entry" style="display:none;" type="text" class="form-control form-control-lg" required> <input value="HOME_FOOTER_LINK" name="entry" style="display:none;" type="text" class="form-control form-control-lg" required>
<h5 style="margin-top:50px">@php foreach($configNames as $obj){if($obj->value == 'HOME_FOOTER_LINK'){echo $obj->title;}}; @endphp</h5> <h5 style="margin-top:50px">@php echo __('messages.HOME_FOOTER_LINK.title'); @endphp</h5>
<p class="text-muted">@php foreach($configNames as $obj){if($obj->value == 'HOME_FOOTER_LINK'){echo $obj->description;}}; @endphp</p> <p class="text-muted">@php echo __('messages.HOME_FOOTER_LINK.description'); @endphp</p>
<div class="input-group"> <div class="input-group">
<input type="url" style="border-radius:.25rem;max-width:600px" class="form-control" name="value" value="{{$configValue}}"> <input type="url" style="border-radius:.25rem;max-width:600px" class="form-control" name="value" value="{{$configValue}}">
<input type="hidden" name="_token" value="{{csrf_token()}}"> <input type="hidden" name="_token" value="{{csrf_token()}}">
@ -450,6 +450,47 @@ document.getElementById("MAINTENANCE_MODE-form").addEventListener("change", func
</form> </form>
{{-- end debug settings --}} {{-- end debug settings --}}
{{-- start language --}}
<a name="Language"><h2 class="ch2">{{__('messages.Language')}}</h2></a>
<?php $configValue2 = str_replace('"', "", EnvEditor::getKey('LOCALE')); ?>
<form id="language-form" action="{{route('editConfig')}}" enctype="multipart/form-data" method="post">
<div class="form-group col-lg-8">
<input value="homeurl" name="type" style="display:none;" type="text" class="form-control form-control-lg" required>
<input value="LOCALE" name="entry" style="display:none;" type="text" class="form-control form-control-lg" required>
<h5 style="margin-top:50px">{{__('messages.LOCALE.title')}}</h5>
<p class="text-muted">{{__('messages.LOCALE.description')}}</p>
<div class="input-group">
<select style="max-width:600px" class="form-control" name="value">
@if($configValue2 != '')
<option>{{$configValue2}}</option>
@endif
<?php
try {
$langFolders = array_filter(glob(base_path('resources/lang') . '/*'), 'is_dir');
} catch (\Exception $e) {
$langFolders = [];
}
foreach($langFolders as $folder) {
$folderName = basename($folder);
if ($folderName != $configValue2) {
echo '<option>' . $folderName . '</option>';
}
}
?>
</select>
</div>
</div>
<input type="hidden" name="_token" value="{{csrf_token()}}">
<script type="text/javascript">
document.getElementById("language-form").addEventListener("change", function() {
this.submit();
});
</script>
</form>
{{-- end language --}}
<br><br><br><br><br> <br><br><br><br><br>
<script src="{{ asset('assets/external-dependencies/jquery-3.4.1.min.js') }}"></script> <script src="{{ asset('assets/external-dependencies/jquery-3.4.1.min.js') }}"></script>

View File

@ -57,6 +57,9 @@ use App\Models\Page;
if(EnvEditor::keyExists('DISPLAY_CREDIT_FOOTER')){ /* Do nothing if key already exists */ if(EnvEditor::keyExists('DISPLAY_CREDIT_FOOTER')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('DISPLAY_CREDIT_FOOTER', 'true');} } else {EnvEditor::addKey('DISPLAY_CREDIT_FOOTER', 'true');}
if(EnvEditor::keyExists('LOCALE')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('LOCALE', 'en');}
if(EnvEditor::keyExists('ADMIN_EMAIL')){} else if(EnvEditor::keyExists('ADMIN_EMAIL')){} else
{if(Auth::user()->id == 1){EnvEditor::addKey('ADMIN_EMAIL', App\Models\User::find(1)->email);} {if(Auth::user()->id == 1){EnvEditor::addKey('ADMIN_EMAIL', App\Models\User::find(1)->email);}
else{EnvEditor::addKey('ADMIN_EMAIL', '');}} else{EnvEditor::addKey('ADMIN_EMAIL', '');}}