Added the ability to dynamically translate on the project website.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
@section('meta_title', __('admin-sections.Links project'))
|
||||
@section('h1', __('admin-sections.Project') . ': ' . $project->name)
|
||||
<x-admin.layout>
|
||||
@include('admin.projects._top')
|
||||
@include('admin.projects.links._top')
|
||||
<div class="row">
|
||||
<div class="col-12 mb-4">
|
||||
<div class="card border-0 shadow components-section">
|
||||
|
@@ -36,6 +36,18 @@
|
||||
</td>
|
||||
</tr>
|
||||
@endcan
|
||||
@can('viewAny', \App\Models\ProjectTranslation::class)
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ route('admin.projects.translations.languages', ['project' => $project->id]) }}" class="fw-bold">
|
||||
<svg width="16" height="16" data-slot="icon" class="align-text-top" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m10.5 21 5.25-11.25L21 21m-9-3h7.5M3 5.621a48.474 48.474 0 0 1 6-.371m0 0c1.12 0 2.233.038 3.334.114M9 5.25V3m3.334 2.364C11.176 10.658 7.69 15.08 3 17.502m9.334-12.138c.896.061 1.785.147 2.666.257m-4.589 8.495a18.023 18.023 0 0 1-3.827-5.802"></path>
|
||||
</svg>
|
||||
{{ __('admin-sections.Translations') }}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endcan
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
@@ -0,0 +1,42 @@
|
||||
@section('meta_title', __('admin-sections.Translations'))
|
||||
@section('h1', __('admin-sections.Project') . ': ' . $project->name)
|
||||
<x-admin.layout>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-4">
|
||||
<div class="card border-0 shadow components-section">
|
||||
<div class="card-body">
|
||||
<h3 id="category" class="mb-4">{{ __('admin-sections.Translations') }}</h3>
|
||||
<div class="table-responsive">
|
||||
<form method="post" action="{{ route('admin.projects.translations.update', ['project' => $project->id, 'language' => $language->id]) }}">
|
||||
<table class="table table-centered table-nowrap mb-0 rounded">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th class="border-0" style="width: 250px;">{{ __('validation.attributes.text') }}</th>
|
||||
<th class="border-0">{{ __('admin-sections.Translations') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($translations as $index => $code)
|
||||
<tr>
|
||||
<td>
|
||||
{{ __($code) }}
|
||||
</td>
|
||||
<td>
|
||||
<x-volt.forms.input-type-hidden :name="'translations[' . $index . '][code]'" :value="$code" />
|
||||
<x-volt.forms.input title="" :name="'translations[' . $index . '][text]'" :value="$projectTranslations[$code] ?? null" />
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@canany(['update'], \App\Models\ProjectTranslation::class)
|
||||
@csrf
|
||||
<button class="btn btn-primary" type="submit">{{ __('Save') }}</button>
|
||||
@endcanany
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-admin.layout>
|
@@ -0,0 +1,36 @@
|
||||
@section('meta_title', __('admin-sections.Translations'))
|
||||
@section('h1', __('admin-sections.Project') . ': ' . $project->name)
|
||||
<x-admin.layout>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-4">
|
||||
<div class="card border-0 shadow components-section">
|
||||
<div class="card-body">
|
||||
<h3 id="category" class="mb-4">{{ __('admin-sections.Translations') }}</h3>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-centered table-nowrap mb-0 rounded">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th class="border-0">{{ __('admin-sections.Languages') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($project->languages as $language)
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ route('admin.projects.translations.edit', ['project' => $project->id, 'language' => $language->id]) }}" class="fw-bold">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="align-text-top" viewBox="0 0 16 16">
|
||||
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/>
|
||||
</svg>
|
||||
{{ $language->title }}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-admin.layout>
|
@@ -1,10 +1,10 @@
|
||||
<div id="language">
|
||||
<div class="language__block">
|
||||
<button class="language__button" type="button" aria-label="{{ __('site.Choose language') }}">
|
||||
<button class="language__button" type="button" aria-label="{{ $websiteTranslations->translate('site.Choose language') }}">
|
||||
<svg width="16" height="16" data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m10.5 21 5.25-11.25L21 21m-9-3h7.5M3 5.621a48.474 48.474 0 0 1 6-.371m0 0c1.12 0 2.233.038 3.334.114M9 5.25V3m3.334 2.364C11.176 10.658 7.69 15.08 3 17.502m9.334-12.138c.896.061 1.785.147 2.666.257m-4.589 8.495a18.023 18.023 0 0 1-3.827-5.802"></path>
|
||||
</svg>
|
||||
{{ $language->title }}
|
||||
{{ $websiteTranslations->getLanguage()->title }}
|
||||
<svg width="16" height="16" class="language__button__str" data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"></path>
|
||||
</svg>
|
||||
|
@@ -1,9 +1,11 @@
|
||||
<div class="mb-4">
|
||||
<label for="form-input-{{ $requestName }}">{{ $title }}
|
||||
@if(!empty($example))
|
||||
<span class="label__example">({{ __('example:') }} {!! $example !!})</span>
|
||||
@endif
|
||||
</label>
|
||||
@if(!empty($title) || !empty($example))
|
||||
<label for="form-input-{{ $requestName }}">{{ $title }}
|
||||
@if(!empty($example))
|
||||
<span class="label__example">({{ __('example:') }} {!! $example !!})</span>
|
||||
@endif
|
||||
</label>
|
||||
@endif
|
||||
<input id="form-input-{{ $requestName }}" class="form-control @error($requestName) is-invalid @enderror" name="{{ $name }}" type="{{ $type }}" @if($type !== 'password') value="{{ $value }}" @endif {{ $attributes }}>
|
||||
@error($requestName)
|
||||
<span class="invalid-feedback">{{ $message }}</span>
|
||||
|
@@ -6,8 +6,10 @@
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th class="border-0 rounded-start">{{ __('validation.attributes.title') }}</th>
|
||||
<th class="border-0">{{ __('validation.attributes.code') }}</th>
|
||||
<th class="border-0">{{ __('validation.attributes.sort') }}</th>
|
||||
<th class="border-0" style="width: 200px;">{{ __('validation.attributes.code') }}</th>
|
||||
<th class="border-0" style="width: 140px;">{{ __('validation.attributes.sort') }}</th>
|
||||
<th class="border-0" style="width: 120px;">{{ __('validation.attributes.iso_code') }}</th>
|
||||
<th class="border-0">{{ __('validation.attributes.system_lang') }}</th>
|
||||
<th class="border-0">{{ __('validation.attributes.is_default') }}</th>
|
||||
<th class="border-0 rounded-end"></th>
|
||||
</tr>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<input class="form-control @error(\App\Helpers\Helpers::formatAttributeNameToRequestName($name)) is-invalid @enderror" name="{{ $name }}" type="{{ $type }}" value="{{ $value }}" required>
|
||||
<input class="form-control @error(\App\Helpers\Helpers::formatAttributeNameToRequestName($name)) is-invalid @enderror" name="{{ $name }}" type="{{ $type }}" value="{{ $value }}" @if($required) required @endif>
|
||||
@error(\App\Helpers\Helpers::formatAttributeNameToRequestName($name))
|
||||
<span class="invalid-feedback">{{ $message }}</span>
|
||||
@enderror
|
||||
|
@@ -3,23 +3,40 @@
|
||||
<input type="hidden" name="{{ $name . '[items][' .$index . '][id]' }}" value="{{ $lang['id'] }}">
|
||||
@endif
|
||||
@include('components.volt.forms.languages.input', [
|
||||
'value' => $lang['title'],
|
||||
'name' => $name . '[items][' .$index . '][title]',
|
||||
'type' => 'text',
|
||||
'value' => $lang['title'],
|
||||
'name' => $name . '[items][' .$index . '][title]',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
])
|
||||
</td>
|
||||
<td>
|
||||
@include('components.volt.forms.languages.input', [
|
||||
'value' => $lang['code'],
|
||||
'name' => $name . '[items][' . $index . '][code]',
|
||||
'type' => 'text',
|
||||
'value' => $lang['code'],
|
||||
'name' => $name . '[items][' . $index . '][code]',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
])
|
||||
</td>
|
||||
<td>
|
||||
@include('components.volt.forms.languages.input', [
|
||||
'value' => $lang['sort'],
|
||||
'name' => $name . '[items][' . $index . '][sort]',
|
||||
'type' => 'number',
|
||||
'value' => $lang['sort'],
|
||||
'name' => $name . '[items][' . $index . '][sort]',
|
||||
'type' => 'number',
|
||||
'required' => true,
|
||||
])
|
||||
</td>
|
||||
<td>
|
||||
@include('components.volt.forms.languages.input', [
|
||||
'value' => $lang['iso_code'] ?? null,
|
||||
'name' => $name . '[items][' . $index . '][iso_code]',
|
||||
'type' => 'text',
|
||||
'required' => false,
|
||||
])
|
||||
</td>
|
||||
<td>
|
||||
@include('components.volt.forms.languages.system_lang', [
|
||||
'value' => $lang['system_lang'] ?? null,
|
||||
'name' => $name . '[items][' . $index . '][system_lang]',
|
||||
])
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
|
@@ -0,0 +1,9 @@
|
||||
<select class="form-select @error(\App\Helpers\Helpers::formatAttributeNameToRequestName($name)) is-invalid @enderror" name="{{ $name }}">
|
||||
<option value=""></option>
|
||||
@foreach(\App\Enums\Lang::cases() as $lang)
|
||||
<option @if($lang->value === $value) selected @endif value="{{ $lang->value }}">{{ $lang->getTitle() }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@error(\App\Helpers\Helpers::formatAttributeNameToRequestName($name))
|
||||
<span class="invalid-feedback">{{ $message }}</span>
|
||||
@enderror
|
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ $language->code }}">
|
||||
<html lang="{{ $websiteTranslations->getLanguage()->attribute_lang }}">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
@@ -14,7 +14,7 @@
|
||||
<div class="wrapper">
|
||||
<header class="header">
|
||||
<div class="header_logo">
|
||||
<a href="{{ \App\Enums\Site\ProjectSection::Home->url($project, $language) }}">
|
||||
<a href="{{ \App\Enums\Site\ProjectSection::Home->url($project, $websiteTranslations->getLanguage()) }}">
|
||||
@if($logo)
|
||||
<img src="{{ $logo->url }}" alt="{{ $project->name }}">
|
||||
@else
|
||||
@@ -22,7 +22,7 @@
|
||||
@endif
|
||||
</a>
|
||||
</div>
|
||||
<button id="mobile-menu" type="button" aria-label="{{ __('site.Menu') }}">
|
||||
<button id="mobile-menu" type="button" aria-label="{{ $websiteTranslations->translate('site.Menu') }}">
|
||||
<svg class="open" width="45" height="45" data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"></path>
|
||||
</svg>
|
||||
@@ -30,13 +30,13 @@
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12"></path>
|
||||
</svg>
|
||||
</button>
|
||||
<x-site.choose-language :language="$language" :languages="$project->languages" />
|
||||
<x-site.choose-language :websiteTranslations="$websiteTranslations" :project="$project" />
|
||||
</header>
|
||||
<div class="main-container">
|
||||
<nav id="menu">
|
||||
<div class="menu__title">{{ __('site.Menu') }}</div>
|
||||
<ul>
|
||||
<li><a href="{{ \App\Enums\Site\ProjectSection::Home->url($project, $language) }}" @class(['active' => request()->route()->named(['home', 'language.home'])])>{{ __('site.About project') }}</a></li>
|
||||
<li><a href="{{ \App\Enums\Site\ProjectSection::Home->url($project, $websiteTranslations->getLanguage()) }}" @class(['active' => request()->route()->named(['home', 'language.home', 'project.home', 'project.language.home'])])>{{ $websiteTranslations->translate('site.About project') }}</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="section-container">
|
||||
@@ -45,7 +45,7 @@
|
||||
{{ $slot }}
|
||||
</div>
|
||||
<footer class="footer">
|
||||
<a href="https://git.kor-elf.net/kor-elf/my-projects-website" target="_blank">{{ __('site.Powered by service') }}</a>
|
||||
<a href="https://git.kor-elf.net/kor-elf/my-projects-website" target="_blank">{{ $websiteTranslations->translate('site.Powered by service') }}</a>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
@section('h1', __('site.Page without translation'))
|
||||
@section('h1', $websiteTranslations->translate('site.Page without translation'))
|
||||
|
||||
<x-site.layout :project="$project" :language="$language">
|
||||
<x-site.layout :project="$project" :websiteTranslations="$websiteTranslations">
|
||||
|
||||
</x-site.layout>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
@section('meta_title', __('site.Project') . ': ' . $content->title)
|
||||
@section('meta_title', $websiteTranslations->translate('site.Project') . ': ' . $content->title)
|
||||
@section('h1', $content->title)
|
||||
|
||||
<x-site.layout :project="$project" :language="$language">
|
||||
<x-site.layout :project="$project" :websiteTranslations="$websiteTranslations">
|
||||
{!! $content->description !!}
|
||||
</x-site.layout>
|
||||
|
Reference in New Issue
Block a user