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

Add boostrap 4 support and pagination #365

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,29 @@
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
},
{
"name": "KalimeroMK",
"email": "zbogoevski@gmail.com"
}
],
"require": {
"php": ">=7",
"illuminate/support": "^5.5|^6|^7",
"illuminate/translation": "^5.5|^6|^7",
"symfony/finder": "^3|^4|^5",
"tanmuhittin/laravel-google-translate": "^1.0.2"
"illuminate/support": "^9|^10|^11",
"illuminate/translation": "^9|^10|^11",
"symfony/finder": "^6"
"tanmuhittin/laravel-google-translate": "^2.0.1"
},
"autoload": {
"psr-4": {
"Barryvdh\\TranslationManager\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Barryvdh\\TranslationManager\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "0.5-dev"
Expand Down
54 changes: 45 additions & 9 deletions config/translation-manager.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Routes group config
Expand All @@ -10,19 +9,19 @@
| The default group settings for the elFinder routes.
|
*/
'route' => [
'prefix' => 'translations',
'route' => [
'prefix' => 'translations',
'middleware' => 'auth',
],

/**
/*
* Enable deletion of translations
*
* @type boolean
*/
'delete_enabled' => true,

/**
/*
* Exclude specific groups from Laravel Translation Manager.
* This is useful if, for example, you want to avoid editing the official Laravel language files.
*
Expand All @@ -36,7 +35,7 @@
*/
'exclude_groups' => [],

/**
/*
* Exclude specific languages from Laravel Translation Manager.
*
* @type array
Expand All @@ -46,12 +45,12 @@
* 'de',
* )
*/
'exclude_langs' => [],
'exclude_langs' => [],

/**
/*
* Export translations with keys output alphabetically.
*/
'sort_keys' => false,
'sort_keys' => false,

'trans_functions' => [
'trans',
Expand All @@ -66,4 +65,41 @@
'$trans.get',
],

'models' => [
// \App\Models\Post::class,
// \App\Models\Category::class,
],

'model-field-source' => 'translatable',

/*
* Database connection name to allow for different db connection for the translations table.
*/
'db_connection' => env('TRANSLATION_MANAGER_DB_CONNECTION', null),

/*
* Enable pagination of translations
*
* @type boolean
*/
'pagination_enabled' => false,

/*
* Define number of translations per page
*
* @type integer
*/
'per_page' => 40,

/* ------------------------------------------------------------------------------------------------
| Set Views options
| --------------------------å----------------------------------------------------------------------
| Here you can set The "extends" blade of index.blade.php
*/
'layout' => 'translation-manager::layout',

/*
* Choose which template to use [bootstrap3, bootstrap4, bootstrap5, tailwind3 ]
*/
'template' => 'tailwind3',
];
38 changes: 16 additions & 22 deletions database/migrations/2014_04_02_193005_create_translations_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTranslationsTable extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ltm_translations', function(Blueprint $table)
{
$table->collation = 'utf8mb4_bin';
class CreateTranslationsTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ltm_translations', static function (Blueprint $table) {
$table->collation = 'utf8mb4_bin';
$table->bigIncrements('id');
$table->integer('status')->default(0);
$table->string('locale');
Expand All @@ -23,16 +20,13 @@ public function up()
$table->text('value')->nullable();
$table->timestamps();
});
}
}

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

}
}
59 changes: 35 additions & 24 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## Laravel 5 Translation Manager
## Laravel Translation Manager

### For Laravel 4, please use the [0.1 branch](https://github.com/barryvdh/laravel-translation-manager/tree/0.1)!
[![Tests](https://github.com/barryvdh/laravel-translation-manager/actions/workflows/run-tests.yml/badge.svg)](https://github.com/barryvdh/laravel-translation-manager/actions)
[![Packagist License](https://poser.pugx.org/barryvdh/laravel-translation-manager/license.png)](http://choosealicense.com/licenses/mit/)
[![Latest Stable Version](https://poser.pugx.org/barryvdh/laravel-translation-manager/version.png)](https://packagist.org/packages/barryvdh/laravel-translation-manager)
[![Total Downloads](https://poser.pugx.org/barryvdh/laravel-translation-manager/d/total.png)](https://packagist.org/packages/barryvdh/laravel-translation-manager)
[![Fruitcake](https://img.shields.io/badge/Powered%20By-Fruitcake-b2bc35.svg)](https://fruitcake.nl/)

This is a package to manage Laravel translation files.
It does not replace the Translation system, only import/export the php files to a database and make them editable through a webinterface.
Expand All @@ -22,42 +26,40 @@ Require this package in your composer.json and run composer update (or run `comp

composer require barryvdh/laravel-translation-manager

After updating composer, add the ServiceProvider to the providers array in `config/app.php`

'Barryvdh\TranslationManager\ManagerServiceProvider',

You need to run the migrations for this package.

$ php artisan vendor:publish --provider="Barryvdh\TranslationManager\ManagerServiceProvider" --tag=migrations
$ php artisan migrate
```
php artisan vendor:publish --provider="Barryvdh\TranslationManager\ManagerServiceProvider" --tag=migrations
php artisan migrate
```

You need to publish the config file for this package. This will add the file `config/translation-manager.php`, where you can configure this package.

$ php artisan vendor:publish --provider="Barryvdh\TranslationManager\ManagerServiceProvider" --tag=config
```
php artisan vendor:publish --provider="Barryvdh\TranslationManager\ManagerServiceProvider" --tag=config
```

In order to edit the default template, the views must be published as well. The views will then be placed in `resources/views/vendor/translation-manager`.

$ php artisan vendor:publish --provider="Barryvdh\TranslationManager\ManagerServiceProvider" --tag=views
```
php artisan vendor:publish --provider="Barryvdh\TranslationManager\ManagerServiceProvider" --tag=views
```

Routes are added in the ServiceProvider. You can set the group parameters for the routes in the configuration.
You can change the prefix or filter/middleware for the routes. If you want full customisation, you can extend the ServiceProvider and override the `map()` function.

This example will make the translation manager available at `http://yourdomain.com/translations`

If you would like to use auto translation using Google Translate API
If you would like to use auto translation using Google Translate API, install https://github.com/tanmuhittin/laravel-google-translate

```
composer require tanmuhittin/laravel-google-translate
php artisan vendor:publish --provider=Tanmuhittin\LaravelGoogleTranslate\LaravelGoogleTranslateServiceProvider
```

Edit config/laravel_google_translate.php and add your Google Translate API key.

```
php artisan config:cache
```

Now you can use Auto Translation Trait

### Laravel >= 5.2
### Middleware / Auth

The configuration file by default only includes the `auth` middleware, but the latests changes in Laravel 5.2 makes it that session variables are only accessible when your route includes the `web` middleware. In order to make this package work on Laravel 5.2, you will have to change the route/middleware setting from the default

Expand Down Expand Up @@ -98,7 +100,9 @@ You can also use the commands below.

The import command will search through app/lang and load all strings in the database, so you can easily manage them.

$ php artisan translations:import
```
php artisan translations:import
```

Translation strings from app/lang/locale.json files will be imported to the __json_ group.

Expand All @@ -111,7 +115,9 @@ The Find command/button will look search for all php/twig files in the app direc
The found keys will be added to the database, so they can be easily translated.
This can be done through the webinterface, or via an Artisan command.

$ php artisan translations:find
```
php artisan translations:find
```

If your project uses translation strings as keys, these will be stored into then __json_ group.

Expand All @@ -121,7 +127,9 @@ The export command will write the contents of the database back to app/lang php
This will overwrite existing translations and remove all comments, so make sure to backup your data before using.
Supply the group name to define which groups you want to publish.

$ php artisan translations:export <group>
```
php artisan translations:export <group>
```

For example, `php artisan translations:export reminders` when you have 2 locales (en/nl), will write to `app/lang/en/reminders.php` and `app/lang/nl/reminders.php`

Expand All @@ -131,14 +139,17 @@ To export translation strings as keys to JSON files , use the `--json` (or `-J`)

The clean command will search for all translation that are NULL and delete them, so your interface is a bit cleaner. Note: empty translations are never exported.

$ php artisan translations:clean
```
php artisan translations:clean
```

### Reset command

The reset command simply clears all translation in the database, so you can start fresh (by a new import). Make sure to export your work if needed before doing this.

$ php artisan translations:reset

```
php artisan translations:reset
```


### Detect missing translations
Expand Down
Loading