added translate for form name

This commit is contained in:
decoder 2024-03-06 23:11:10 +05:00
parent c18c2d0f32
commit fd9dc5d545
8 changed files with 1809 additions and 1398 deletions

View File

@ -191,7 +191,7 @@ class FormController extends Controller
public function update($id)
{
try {
$input = request()->only('name', 'description', 'slug');
$input = request()->only('name', 'name_ru', 'name_est', 'description', 'slug');
$form_data = [
'form' => request()->input('form'),
'emailConfig' => request()->input('email_config'),
@ -210,6 +210,8 @@ class FormController extends Controller
$form = Form::find($id);
$form->name = $input['name'];
$form->name_ru = $input['name_ru'];
$form->name_est = $input['name_est'];
$form->slug = $input['slug'];
$form->description = $input['description'];
$form->schema = $input['schema'];

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\UserSetting;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Session;
@ -17,6 +18,14 @@ class LocaleController extends Controller
app()->setLocale($locale);
$userSetting = UserSetting::where('user_id', auth()->user()->id)->first();
if (!empty($userSetting)) {
$userSetting->update([
'language' => $locale
]);
}
return redirect()->back();
}
}

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\UserSetting;
use DateTimeZone;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;
class ManageSettingsController extends Controller
{
@ -57,6 +58,14 @@ class ManageSettingsController extends Controller
$setting = UserSetting::where('user_id', $input['user_id'])->first();
if (! in_array($request->language, ['en', 'ru', 'est'])) {
abort(400);
}
Session::put('locale', $request->language);
app()->setLocale($request->language);
if (empty($setting)) {
UserSetting::create($input);
} else {

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forms', function (Blueprint $table) {
$table->string('name_ru')->after('name')->nullable();
$table->string('name_est')->after('name_ru')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forms', function (Blueprint $table) {
//
});
}
};

View File

@ -685,4 +685,6 @@ return [
'placeholder_ru' => 'Placeholder in Ru',
'options_est' => 'Options in est',
'options_ru' => 'Options in Ru',
'form_name_est' => 'Form Name est',
'form_name_ru' => 'Form Name ru',
];

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -178,6 +178,15 @@
@section('footer')
<script type="text/javascript">
$(document).ready(function () {
var lang = `{{session()->get('locale')}}`
var titleColName = 'name';
console.log(lang);
if (lang === 'est') {
titleColName = 'name_est'
} else if (lang === 'ru') {
titleColName = 'name_ru'
}
// form dataTable
var form_table = $('#form_table').DataTable({
@ -196,7 +205,15 @@
{"width": "20%", "targets": 4}
],
columns: [
{data: 'name', name: 'name'},
{
data: titleColName,
name: titleColName,
createdCell: function (td, cellData, rowData, row, col) {
if (td.innerHTML.length === 0) {
td.innerHTML = rowData.name
}
},
},
{data: 'description', name: 'description'},
{data: 'created_at', name: 'created_at'},
{data: 'data_count', name: 'data_count', searchable: false},