Skip to content
Permalink
Browse files

Move all text strings to lang file

  • Loading branch information...
dignityinside committed Jun 20, 2019
1 parent 1a8c3d1 commit 2983d2d10b84ee9776ef3b2aec38f139d1b141dc
@@ -3,6 +3,7 @@ APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://phpland.test
APP_LOCALE=en

LOG_CHANNEL=stack

@@ -64,7 +64,7 @@ public function store(PageRequest $pageRequest): RedirectResponse
Page::create($pageRequest->validated());
return redirect()->back()->with('message', 'Страница добавлена!');
return redirect()->back()->with('message', __('pages.page_added'));
}
/**
@@ -103,7 +103,7 @@ public function update(PageRequest $pageRequest, Page $page): RedirectResponse
{
$page->update($pageRequest->validated());
return redirect()->back()->with('message', 'Страница сохранена!');
return redirect()->back()->with('message', __('pages.page_saved'));
}
/**
@@ -11,7 +11,7 @@
*
* @package App
*
* @author Alexander Schilling <dignityinside@protonmail.com>
* @author Alexander Schilling <dignityinside@protonmail.com>
*/
class Page extends Model
{
@@ -33,27 +33,6 @@ class Page extends Model
'material_id',
];
public const CATEGORIES = [
0 => 'Выберите категорию',
1 => 'Веб-программирование',
2 => 'SEO',
3 => 'Софт',
4 => 'Сервер',
5 => 'Игры',
6 => 'Разное',
7 => 'Истории успеха',
];
public const STATUS = [
'draft' => 'Черновик',
'public' => 'Опубликовать',
];
public const MATERIALS = [
'blog' => 'Блог',
'static' => 'Страница',
];
/**
* Get the route key for the model.
*
@@ -84,6 +63,52 @@ public function getFullContent(): string
return Text::hideCut($this->getHtmlContent());
}
/**
* Returns materials list
*
* @return array
*/
public function getMaterials(): array
{
return [
'blog' => __('pages.material_blog'),
'static' => __('pages.material_static'),
];
}
/**
* Returns categories list
*
* @return array
*/
public function getCategories(): array
{
return [
0 => __('pages.categories_default'),
1 => 'Веб-программирование',
2 => 'SEO',
3 => 'Софт',
4 => 'Сервер',
5 => 'Игры',
6 => 'Разное',
7 => 'Истории успеха',
];
}
/**
* Returns status
*
* @return array
*/
public function getStatus(): array
{
return [
'draft' => __('pages.status_draft'),
'public' => __('pages.status_public'),
];
}
/**
* Returns html content
*
@@ -1,7 +1,7 @@
{
"name": "laravel/laravel",
"name": "dignityinside/phpland_laravel",
"type": "project",
"description": "The Laravel Framework.",
"description": "Source code of phpland community.",
"keywords": [
"framework",
"laravel"
@@ -80,7 +80,7 @@
|
*/
'locale' => 'en',
'locale' => env('APP_LOCALE', 'en'),
/*
|--------------------------------------------------------------------------
@@ -13,7 +13,9 @@
|
*/
'failed' => 'These credentials do not match our records.',
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
'failed' => 'These credentials do not match our records.',
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
'dashboard' => 'Dashboard',
'message_logged_in' => 'You are logged in!',
];
@@ -0,0 +1,46 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Pages Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used during page for various
| messages that we need to display to the user. You are free to modify
| these language lines according to your application's requirements.
|
*/
'create_page_headline' => 'Create page',
'edit_page_headline' => 'Edit page',
'button_remove' => 'Delete page',
'draft' => 'Draft',
'edit' => 'Edit',
'views' => 'Views',
'category' => 'Category',
'comments' => 'Comments',
'type' => 'Type',
'title' => 'Title',
'permalink' => 'Permalink',
'text' => 'Text',
'status' => 'Status',
'allow_comments' => 'Allow Comments',
'add_mainstream' => 'Add to mainstream',
'save' => 'Save',
'material_blog' => 'Blog',
'material_static' => 'Static',
'status_draft' => 'Draft',
'status_public' => 'Public',
'categories_default' => 'Select category',
'page_added' => 'Page is added!',
'page_saved' => 'Page is saved!',
];
@@ -5,7 +5,9 @@
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Dashboard</div>
<div class="card-header">
@lang('auth.dashboard')
</div>

<div class="card-body">
@if (session('status'))
@@ -14,7 +16,7 @@
</div>
@endif

You are logged in!
@lang('auth.message_logged_in')
</div>
</div>
</div>
@@ -2,7 +2,7 @@

@section('content')

<h1>Добавить страницу</h1>
<h1>@lang('pages.create_page_headline')</h1>

@include('partials.error')

@@ -2,13 +2,14 @@

@section('content')

<h1>Изменить страницу</h1>
<h1>@lang('pages.edit_page_headline')</h1>

@include('partials.error')

<form method="post" action="{{ route('page.update', ['slug' => $page->slug]) }}">

@method('PATCH')

@csrf

@include('pages.form')
@@ -21,7 +22,7 @@
@csrf

<div class="form-group">
<button type="submit" class="btn btn-submit">Удалить</button>
<button type="submit" class="btn btn-submit">@lang('pages.button_remove')</button>
</div>

</form>
@@ -1,9 +1,11 @@
@csrf

<div class="form-group">
<label for="material_id">Тип страницы</label>
<label for="material_id">
@lang('pages.type')
</label>
<select class="form-control" name="material_id" id="material_id">
@foreach ($page::MATERIALS as $key => $value)
@foreach ($page->getMaterials() as $key => $value)
<option value="{{ $key }}" {{ ( $key == old('material_id', $page->material_id ?? null)) ? 'selected' : '' }}>
{{ $value }}
</option>
@@ -15,9 +17,11 @@
</div>

<div class="form-group">
<label for="category_id">Категория</label>
<label for="category_id">
@lang('pages.category')
</label>
<select class="form-control" name="category_id" id="category_id">
@foreach ($page::CATEGORIES as $key => $value)
@foreach ($page->getCategories() as $key => $value)
<option value="{{ $key }}" {{ ( $key == old('category_id', $page->category_id ?? null)) ? 'selected' : '' }}>
{{ $value }}
</option>
@@ -29,23 +33,29 @@
</div>

<div class="form-group">
<label for="title">Заголовок</label>
<label for="title">
@lang('pages.title')
</label>
<input type="text" name="title" class="form-control @error('title') is-invalid @enderror" id="title" value="{{ old('title', $page->title ?? null) }}">
@error('title')
<div class="text-danger">{{ $message }}</div>
@enderror
</div>

<div class="form-group">
<label for="slug">Постоянная ссылка</label>
<label for="slug">
@lang('pages.permalink')
</label>
<input type="text" name="slug" class="form-control @error('slug') is-invalid @enderror" id="slug" value="{{ old('slug', $page->slug ?? null) }}">
@error('slug')
<div class="text-danger">{{ $message }}</div>
@enderror
</div>

<div class="form-group">
<label for="content">Текст</label>
<label for="content">
@lang('pages.text')
</label>
<span v-pre>
<textarea name="content" class="form-control @error('content') is-invalid @enderror" id="content">
{{ old('content', $page->content ?? null) }}
@@ -57,9 +67,11 @@
</div>

<div class="form-group">
<label for="status_id">Статус</label>
<label for="status_id">
@lang('pages.status')
</label>
<select class="form-control" name="status_id" id="status_id">
@foreach ($page::STATUS as $key => $value)
@foreach ($page->getStatus() as $key => $value)
<option value="{{ $key }}" {{ ( $key == old('status_id', $page->status_id ?? null)) ? 'selected' : '' }}>
{{ $value }}
</option>
@@ -74,7 +86,9 @@
<div class="form-check">
<input type="hidden" name="allow_comments" value="0">
<input class="form-check-input" type="checkbox" name="allow_comments" id="allow_comments" {{ old('allow_comments', $page->allow_comments ?? null) ? 'checked' : '' }} value="1">
<label class="form-check-label" for="allow_comments">Разрешить комментарии</label>
<label class="form-check-label" for="allow_comments">
@lang('pages.allow_comments')
</label>
</div>
@error('allow_comments')
<div class="text-danger">{{ $message }}</div>
@@ -85,13 +99,17 @@
<div class="form-check">
<input type="hidden" name="mainstream" value="0">
<input class="form-check-input" type="checkbox" name="mainstream" id="mainstream" {{ old('mainstream', $page->mainstream ?? null) ? 'checked' : '' }} value="1">
<label class="form-check-label" for="mainstream">Добавить в майнстрим</label>
<label class="form-check-label" for="mainstream">
@lang('pages.add_mainstream')
</label>
</div>
@error('mainstream')
<div class="text-danger">{{ $message }}</div>
@enderror
</div>

<div class="form-group">
<button type="submit" class="btn btn-success btn-submit">Сохранить</button>
<button type="submit" class="btn btn-success btn-submit">
@lang('pages.save')
</button>
</div>
@@ -5,13 +5,13 @@
<h1>{{$page->title}}</h1>

@if($page->status_id === 'draft')
(Черновик)
(@lang('pages.draft'))
@endif

@can('update', $page)
<div>
<a href="{{ route('page.edit', ['slug' => $page->slug]) }}">
Редактировать
@lang('pages.edit')
</a>
</div>
@endauth
@@ -24,20 +24,20 @@

@if ($page->hits > 0)
<div>
Просмотров: {{$page->hits}}
@lang('pages.views'): {{$page->hits}}
</div>
@endif

<div>
Категория: {{$page->category_id}}
@lang('pages.category'): {{$page->category_id}}
</div>

<div>
{{$page->created_at->format('d.m.Y')}}
</div>

@if ($page->allow_comments)
<div>Комментарии.</div>
<div>@lang('pages.comments').</div>
@endif

@endsection

0 comments on commit 2983d2d

Please sign in to comment.
You can’t perform that action at this time.