Skip to content

MrAlKuz/Efremov-translate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Setup

-- Add to composer.json

"repositories": [
           {
               "type":"package",
               "package":{
   
                   "name":"sashaef/translateprovider",
                   "version": "dev-master",
                   "source":{
                       "type":"git",
                       "url":"ssh://[email protected]:8415/esv2/translateprovider.git",
                       "reference":"master"
                   }
               }
           }
       ],
"require": {
           ...,
           "sashaef/translateprovider": "dev-master"
       },     

-- Than run composer install and composer update

-- Add to composer.json

"autoload": {
        "psr-4": {
            "App\\": "app/",
            "Sashaef\\TranslateProvider\\": "vendor/sashaef/translateprovider/src/"
        },
}

-- Migrate db

php artisan migrate --path=vendor/sashaef/translateprovider/src/database/migrations

-- Add assets

php artisan vendor:publish --tag=public --force

-- Add config

php artisan vendor:publish --tag=config

-- Add translations

Linux:
php artisan db:seed --class=Sashaef\\TranslateProvider\\Database\\Seeder\\DatabaseSeeder

Windiws:
php artisan db:seed --class=Sashaef\TranslateProvider\Database\Seeder\DatabaseSeeder

-- Add to config/app.php

Sashaef\TranslateProvider\TranslateProvider::class,

-- Remove from config/app.php exists translate module

//Barryvdh\TranslationManager\TranslationServiceProvider::class,

-- Commit line in AppServiceProvider.php

//Resource::withoutWrapping();

-- Add LocaleMiddleware for switch lang

Sashaef\TranslateProvider\Models\Langs\LocaleMiddleware;

Admin

-- Path

/admin/trans

-- Add menu

<li {{ $segment2 == 'translates'?'class=active':''}}>
    <a {{ $segment2 == 'translates'?'class=active':''}}>
        <i class="fa fa-language"></i>
        <span>@lang('main.translations')</span>
    </a>
    <ul>
        <li {{ $segment3 == 'black'?'class=active':''}}>
            <a {{ $segment3 == 'black'?'class=active':''}} href="{{ route('translate.langs.index') }}">
                <i class="fa fa-circle-o"></i>
                <span>@lang('main.languages')</span>
            </a>
        </li>
        <li {{ $segment3 == 'black'?'class=active':''}}>
            <a {{ $segment3 == 'black'?'class=active':''}} href="{{ route('translate.groups.type', ['type' => 'interface']) }}">
                <i class="fa fa-circle-o"></i>
                <span>@lang('main.interface-trans')</span>
            </a>
        </li>
        <li {{ $segment3 == 'white'?'class=active':''}}>
            <a {{ $segment3 == 'white'?'class=active':''}} href="{{ route('translate.groups.type', ['type' => 'system']) }}">
                <i class="fa fa-circle-o"></i>
                <span>@lang('main.system-trans')</span>
            </a>
        </li>
    </ul>
</li>

-- config

'url' => '/admin/translates',
'middleware' => ['web', ...] get from admin route,
'layout' => 'layouts.admin',
'show_full_key' => true,

Key structure in Redis

[type = interface, system]:[group = main]:[key = new_translation]:[langId = 2]

Key structure for Laravel function trans() or @lang()

[null|interface, system]::[group name].[translate key]
Example: main.translate or system::main.translate or interface::main.translate

API path

route - /translate

@params - "type" (interface: default, system)
@params - "lang" (en: default)
@params - "keys" (array)
Example: /translate?lang=en

Cach translations after clear cache Redis

php artisan translate:cache

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •