Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.6 #391

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
27 changes: 27 additions & 0 deletions config/translation-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,31 @@
'$trans.get',
],

/**
* if true finding new translations will be disabled while users browse application
*/
'ignore_new_trans' => false,

/**
* When project does not user JSON alternative it can be ignored
*/
'ignore_json' => true,

/**
* Translations without source position will be marked as red
*/
'warn_in_code' => false,

/*
|--------------------------------------------------------------------------
| DEBUG
|--------------------------------------------------------------------------
|
| After every translation will be placed original key in square brackets
| e.g.: trans('auth.login') -> Login [auth.login]
| NOTE: only when translation exists!
|
*/
'debug' => false,

];
45 changes: 25 additions & 20 deletions database/migrations/2014_04_02_193005_create_translations_table.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateTranslationsTable extends Migration {
class CreateTranslationsTable
extends Migration
{

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ltm_translations', function(Blueprint $table)
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ltm_translations', function (Blueprint $table)
{
$table->collation = 'utf8mb4_bin';
$table->collation = 'utf8mb4_bin';
$table->bigIncrements('id');
$table->integer('status')->default(0);
$table->string('locale');
$table->string('group');
$table->text('key');
$table->text('value')->nullable();
$table->timestamps();

$table->index(['group']);
$table->index(['locale']);
});
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ltm_translations');
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateLtmTranslationsSourcesTable
extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ltm_translation_sources', function (Blueprint $table)
{
$table->bigIncrements('id');

$table->string('group');
$table->text('key');

$table->string('file_path');
$table->integer('file_line');

$table->index(['group', 'key']);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('ltm_translation_sources');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateLtmTranslationsUrlsTable
extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ltm_translation_urls', function (Blueprint $table)
{
$table->bigIncrements('id');

$table->string('group');
$table->text('key');

$table->string('url');

$table->index(['group', 'key']);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('ltm_translation_urls');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateLtmTranslationsVariablesTable
extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ltm_translation_variables', function (Blueprint $table)
{
$table->bigIncrements('id');

$table->string('group');
$table->text('key');

$table->string('attribute');

$table->index(['group', 'key']);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('ltm_translation_variables');
}
}
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The workflow would be:
This way, translations can be saved in git history and no overhead is introduced in production.

![Screenshot](http://i.imgur.com/4th2krf.png)
![Screenshot](screenshot2.png)

## Installation

Expand Down
45 changes: 45 additions & 0 deletions resources/views/components/locales_list.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<fieldset>
<legend>Supported locales</legend>
<p>
Current supported locales:
</p>
<form class="form-remove-locale" method="POST" role="form" action="{{ action('\Barryvdh\TranslationManager\Controller@postRemoveLocale') }}" data-confirm="Are you sure to remove this locale and all of data?">
@csrf
<ul class="list-locales">
@foreach($locales as $locale)
<li>
<div class="form-group">
<button type="submit" name="remove-locale[{{ $locale }}]" class="btn btn-danger btn-xs" data-disable-with="...">
&times;
</button>
{{ $locale }}

</div>
</li>
@endforeach
</ul>
</form>
<form class="form-add-locale" method="POST" role="form" action="{{ action('\Barryvdh\TranslationManager\Controller@postAddLocale') }}">
@csrf
<div class="form-group">
<p>
Enter new locale key:
</p>
<div class="row">
<div class="col-sm-3">
<input type="text" name="new-locale" class="form-control" />
</div>
<div class="col-sm-2">
<button type="submit" class="btn btn-default btn-block" data-disable-with="Adding..">Add new locale</button>
</div>
</div>
</div>
</form>
</fieldset>
<fieldset>
<legend>Export all translations</legend>
<form class="form-inline form-publish-all" method="POST" action="{{ action('\Barryvdh\TranslationManager\Controller@postPublish', '*') }}" data-remote="true" role="form" data-confirm="Are you sure you want to publish all translations group? This will overwrite existing language files.">
@csrf
<button type="submit" class="btn btn-primary" data-disable-with="Publishing.." >Publish all</button>
</form>
</fieldset>
22 changes: 22 additions & 0 deletions resources/views/components/post_import.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<form class="form-import" method="POST" action="{{ action('\Barryvdh\TranslationManager\Controller@postImport') }}" data-remote="true" role="form">
@csrf
<div class="form-group">
<div class="row">
<div class="col-sm-3">
<select name="replace" class="form-control">
<option value="0">Append new translations</option>
<option value="1">Replace existing translations</option>
</select>
</div>
<div class="col-sm-2">
<button type="submit" class="btn btn-success btn-block" data-disable-with="Loading..">Import groups</button>
</div>
</div>
</div>
</form>
<form class="form-find" method="POST" action="{{ action('\Barryvdh\TranslationManager\Controller@postFind') }}" data-remote="true" role="form" data-confirm="Are you sure you want to scan you app folder? All found translation keys will be added to the database.">
<div class="form-group">
@csrf
<button type="submit" class="btn btn-info" data-disable-with="Searching.." >Find translations in files</button>
</div>
</form>
5 changes: 5 additions & 0 deletions resources/views/components/post_publish.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<form class="form-inline form-publish" method="POST" action="{{ action('\Barryvdh\TranslationManager\Controller@postPublish', $group) }}" data-remote="true" role="form" data-confirm="Are you sure you want to publish the translations group '{{ $group }}? This will overwrite existing language files.">
@csrf
<button type="submit" class="btn btn-info" data-disable-with="Publishing.." >Publish translations</button>
<a href="{{ route('translation-manager.index') }}" class="btn btn-default">Back</a>
</form>
14 changes: 14 additions & 0 deletions resources/views/components/search.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<fieldset>
<legend>Search</legend>
<form role="form" method="get" action="{{ route('translation-manager.search') }}">
<div class="form-group">
<p>Search for translation text</p>
<div class="input-group">
<input type="text" class="form-control" name="q" value="{{ $q ?? "" }}"/>
<div class="input-group-btn">
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span> Search</button>
</div>
</div>
</div>
</form>
</fieldset>
79 changes: 79 additions & 0 deletions resources/views/components/translation_detail.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php $_translation = null ?>
<div class="col-sm-8">
<form class="form-add-locale" method="POST" role="form"
action="{{ route('translation-manager.translation.edit-all', [ "groupKey" => $group, "translationKey" => $key]) }}">
@csrf

<div class="form-group">
<label>group</label>
<input class="form-control" readonly value="{{ $group }}"/>
</div>
<div class="form-group">
<label>key</label>
<input class="form-control" readonly value="{{ $key }}"/>
</div>
@foreach($locales as $localeKey => $locale)
<?php
if (isset($translations[ $key ][ $locale ])) {
$_translation = $translations[ $key ][ $locale ];
}
?>
<div class="form-group {{ isset($translations[$key][$locale]) && $translations[$key][$locale] != "" ? "has-success" : "has-error" }}">
<label class="control-label">{{ $locale }}</label>
<textarea class="form-control" rows="3" name="value[{{ $locale }}]"
placeholder="">{!! isset($translations[$key][$locale]) ? $translations[$key][$locale]->value : "" !!}</textarea>
</div>
@endforeach
<div class="form-group row">
<div class="col-xs-4">
<input type="submit" value="Save" class="btn btn-primary">
<a href="{{ route( 'translation-manager.group.list', [ "groupKey" => $group ] ) }}"
class="btn btn-default">Cancel</a>

</div>
<div class="col-xs-8 text-right">
<div class="btn-group">
@if( $prevTranslation != null )
<a href="{{ route( 'translation-manager.translation', [ "groupKey" => $prevTranslation['group'], "translationKey" => $prevTranslation['key'] ] ) }}"
class="btn btn-default"><span
class="glyphicon glyphicon-chevron-left"></span> {{ $prevTranslation['key'] }}</a>
@endif
<a href="#" class="btn btn-default disabled">{{ $key }}</a>
@if( $nextTranslation != null )
<a href="{{ route( 'translation-manager.translation', [ "groupKey" => $nextTranslation['group'], "translationKey" => $nextTranslation['key'] ] ) }}"
class="btn btn-default">{{ $nextTranslation['key'] }} <span
class="glyphicon glyphicon-chevron-right"></span></a>
@endif
</div>
</div>
</div>
</form>
</div>
@if( $_translation != null )
<div class="col-sm-4">
<fieldset>
<legend>Variables</legend>
<ul>
@foreach( \Barryvdh\TranslationManager\Models\Translation::possibleVariables( $group, $key)->get() as $entry )
<li>{{ $entry->attribute }}</li>
@endforeach
</ul>
</fieldset>
<fieldset>
<legend>URLs</legend>
<ul>
@foreach( \Barryvdh\TranslationManager\Models\Translation::urls( $group, $key)->get() as $entry )
<li>{{ $entry->url }}</li>
@endforeach
</ul>
</fieldset>
<fieldset>
<legend>Source Locations</legend>
<ul>
@foreach( \Barryvdh\TranslationManager\Models\Translation::sourceLocations( $group, $key)->get() as $entry )
<li>{{ $entry->file_path }}:{{ $entry->file_line }}</li>
@endforeach
</ul>
</fieldset>
</div>
@endif
Loading