Code Monkey home page Code Monkey logo

translation's Introduction

Better localization management for Laravel

Latest Version on Packagist Software License Build Status Total Downloads

Introduction

Keeping a project's translations properly updated is cumbersome. Usually translators do not have access to the codebase, and even when they do it's hard to keep track of which translations are missing for each language or when updates to the original text require that translations be revised.

This package allows developers to leverage their database and cache to manage multilanguage sites, while still working on language files during development and benefiting from all the features Laravel's Translation bundle has, like pluralization or replacement.

WAAVI is a web development studio based in Madrid, Spain. You can learn more about us at waavi.com

Table of contents

Laravel compatibility

Laravel translation
4.x 1.0.x
5.0.x 2.0.x
5.1.x|5.3.x 2.1.x
5.4.x 2.2.x
5.5.x 2.3.x and higher
5.6.x 2.3.x and higher
6.x|7.x 2.4.x and higher

Features overview

  • Allow dynamic changes to the site's text and translations.
  • Cache your localization entries.
  • Load your translation files into the database.
  • Force your urls to be localized (ex: /home -> /es/home) and set the locale automatically through the browser's config.
  • Localize your model attributes.

Installation

Require through composer

composer require waavi/translation 2.3.x

Or manually edit your composer.json file:

"require": {
	"waavi/translation": "2.3.x"
}

Once installed, in your project's config/app.php file replace the following entry from the providers array:

Illuminate\Translation\TranslationServiceProvider::class

with:

Waavi\Translation\TranslationServiceProvider::class

Remove your config cache:

php artisan config:clear

Publish both the configuration file and the migrations:

php artisan vendor:publish --provider="Waavi\Translation\TranslationServiceProvider"

Execute the database migrations:

php artisan migrate

You may check the package's configuration file at:

config/translator.php

Translations source

This package allows you to load translation from the regular Laravel localization files (in /resources/lang), from the database, from cache or in a mix of the previous for development. You may configure the desired mode of operation through the translator.php config file and/or the TRANSLATION_SOURCE environment variable. Accepted values are:

  • 'files' To load translations from Laravel's language files (default)
  • 'database' To load translations from the database
  • 'mixed' To load translations both from the filesystem and the database, with the filesystem having priority.
  • 'mixed_db' To load translations both from the filesystem and the database, with the database having priority. [v2.1.5.3]

NOTE: When adding the package to an existing Laravel project, 'files' must be used until migrations have been executed.

For cache configuration, please go to cache configuration

Load translations from files

If you do not wish to leverage your database for translations, you may choose to load language lines exclusively through language files. This mode differs from Laravel in that, in case a line is not found in the specified locale, instead of returning the key right away, we first check the default language for an entry. In case you wish to use this mode exclusively, you will need to set the 'available_locales' config file:

config/translator.php
	'available_locales' => ['en', 'es', 'fr'],

Example:

The content in en/validations.php, where 'en' is the default locale, is:

		[
			'missing_name'			=>	'Name is missing',
			'missing_surname'		=>	'Surname is missing',
		];

The content in es/validations.php is:

		[
			'missing_name'			=>	'Falta el nombre',
		];

Output for different keys with 'es' locale:

		trans('validations.missing_name'); 		// 		'Falta el nombre'
		trans('validations.missing_surname'); 	// 		'Surname is missing'
		trans('validations.missing_email'); 	// 		'validations.missing_email'

Load translations from the database

You may choose to load translations exclusively from the database. This is very useful if you intend to allow users or administrators to live edit the site's text and translations. In a live production environment, you will usually want this source mode to be activated with the translation's cache. Please see Loading your files into the database for details on the steps required to use this source mode.

Example:

The content in the languages table is:

	| id | locale | name    |
	-------------------------
	| 1  | en     | english |
	| 2  | es     | spanish |

The relevant content in the language_entries table is:

	| id | locale | namespace | group       | item	          | text                    |
	-------------------------------------------------------------------------------------
	| 1  | en     | *         | validations | missing.name    | Name is missing         |
	| 2  | en     | *         | validations | missing.surname | Surname is missing      |
	| 3  | en     | *         | validations | min_number      | Number is too small     |
	| 4  | es     | *         | validations | missing.name    | Falta nombre   			|
	| 5  | es     | *         | validations | missing.surname | Falta apellido 			|

Output for different keys with es locale:

		trans('validations.missing.name');   //    'Falta nombre'
		trans('validations.min_number');     //    'Number is too small'
		trans('validations.missing.email');  //    'missing_email'

Mixed mode

In mixed mode, both the language files and the database are queried when looking for a group of language lines. Entries found in the filesystem take precedence over the database. This source mode is useful when in development, so that both the filesystem and the user entries are taken into consideration.

Example:

When files and database are set like in the previous examples:
		trans('validations.missing_name');     //    'Falta el nombre'
		trans('validations.missing_surname');  //    'Falta apellido'
		trans('validations.min_number');       //    'Number is too small'
		trans('validations.missing_email');    //    'missing_email'

Loading your files into the database

When using either the database or mixed translation sources, you will need to first load your translations into the database. To do so, follow these steps:

  • Run the migrations detailed in the installation instructions.

  • Add your languages of choice to the database (see Managing Database Languages)

  • Load your language files into the database using the provided Artisan command:

    php artisan translator:load

When executing the artisan command, the following will happen:

  • Non existing entries will be created.
  • Existing entries will be updated except if they're locked. When allowing users to live edit the translations, it is recommended you do it throught the updateAndLock method provided in the Translations repository. This prevents entries being overwritten when reloading translations from files.
  • When an entry in the default locale is edited, all of its translations will be flagged as pending review. This gives translators the oportunity to review translations that might not be correct, but doesn't delete them so as to avoid minor errata changes in the source text from erasing all translations. See Managing translations for details on how to work with unstable translations.

Both vendor files and subdirectories are supported. Please keep in mind that when loading an entry inside a subdirectory, Laravel 5 has changed the syntax to:

	trans('subdir/file.entry')
	trans('package::subdir/file.entry')

Cache translations

Since querying the database everytime a language group must be loaded is grossly inefficient, you may choose to leverage Laravel's cache system. This module will use the same cache configuration as defined by you in app/config/cache.php.

You may enable or disable the cache through the translator.php config file or the 'TRANSLATION_CACHE_ENABLED' environment variable. Config options are:

Env key type description
TRANSLATION_CACHE_ENABLED boolean Enable / disable the translations cache
TRANSLATION_CACHE_TIMEOUT integer Minutes translation items should be kept in the cache.
TRANSLATION_CACHE_SUFFIX string Default is 'translation'. This will be the cache suffix applied to all translation cache entries.

Cache tags

Available since version 2.1.3.8, if the cache store in use allows for tags, the TRANSLATION_CACHE_SUFFIX will be used as the common tag to all cache entries. This is recommended to be able to invalidate only the translation cache, or even just a given locale, namespace and group configuration.

Clearing the cache

Available since version 2.1.3.8, you may clear the translation cache through both an Artisan Command and a Facade. If cache tags are in use, only the translation cache will be cleared. All of your application cache will however be cleared if you cache tags are not available.

Cache flush command:

php artisan translator:flush

In order to access the translation cache, add to your config/app.php files, the following alias:

    'aliases'         => [
        /* ... */
        'TranslationCache' => \Waavi\Translation\Facades\TranslationCache::class,
    ]

Once done, you may clear the whole translation cache by calling:

    \TranslationCache::flushAll();

You may also choose to invalidate only a given locale, namespace and group combination.

    \TranslationCache::flush($locale, $group, $namespace);
  • The locale is the language locale you wish to clear.
  • The namespace is either '*' for your application translation files, or 'package' for vendor translation files.
  • The group variable is the path to the translation file you wish to clear.

For example, say we have the following file in our resources/lang directory: en/auth.php, en/auth/login.php and en/vendor/waavi/login.php. To clear the cache entries for each of them you would call:

    \TranslationCache::flush('en', 'auth', '*');
    \TranslationCache::flush('en', 'auth/login', '*');
    \TranslationCache::flush('en', 'login', 'waavi');

Managing languages and translations in the Database

The recommended way of managing both languages and translations is through the provided repositories. You may circumvent this by saving changes directly through the Language and Translation models, however validation is no longer executed automatically on model save and could lead to instability and errors.

Both the Language and the Translation repositories provide the following methods:

Method Description
hasTable(); Returns true if the corresponding table exists in the database, false otherwise
all($related = [], $perPage = 0); Retrieve all records from the DB. A paginated record will be return if the second argument is > 0, with $perPage items returned per page
find($id); Find a record by id
create($attributes); Validates the given attributes and inserts a new record. Returns false if validation errors occured
delete($id); Delete a record by id
restore($id); Restore a record by id
count(); Return the total number of entries
validate(array $attributes); Checks if the given attributes are valid
validationErrors(); Get validation errors for create and update methods

Managing Languages

Language management should be done through the \Waavi\Translation\Repositories\LanguageRepository to ensure proper data validation before inserts and updates. It is recommended that you instantiate this class through Dependency Injection.

A valid Language record requires both its name and locale to be unique. It is recommended you use the native name for each language (Ex: English, Español, Français)

The provided methods are:

Method Description
update(array $attributes); Updates a Language entry [id, name, locale]
trashed($related = [], $perPage = 0); Retrieve all trashed records from the DB.
findTrashed($id, $related = []); Find a trashed record by id
findByLocale($locale); Find a record by locale
findTrashedByLocale($locale); Finds a trashed record by locale
allExcept($locale); Returns a list of all languages excluding the given locale
availableLocales(); Returns a list of all available locales
isValidLocale($locale); Checks if a language exists with the given locale
percentTranslated($locale); Returns the percent translated for the given locale

Managing Translations

Translation management should be done through the \Waavi\Translation\Repositories\TranslationRepository to ensure proper data validation before inserts and updates. It is recommended that you instantiate this class through Dependency Injection.

A valid translation entry cannot have the same locale and language code than another.

The provided methods are:

Method Description
update($id, $text); Update an unlocked entry
updateAndLock($id, $text); Update and lock an entry (locked or not)
allByLocale($locale, $perPage = 0); Get all by locale
untranslated($locale, $perPage = 0, $text = null); Get all untranslated entries. If $text is set, entries will be filtered by partial matches to translation value.
pendingReview($locale, $perPage = 0); List all entries pending review
search($locale, $term, $perPage = 0); Search by all entries by locale and a partial match to both the text value and the translation code.
randomUntranslated($locale); Get a random untranslated entry
translateText($text, $textLocale, $targetLocale); Translate text to another locale
flagAsReviewed($id); Flag entry as reviewed

Things to consider:

  • You may lock translations so that they can only be updated through updateAndLock. The language file loader uses the update method and will not be able to override locked translations.
  • When a text entry belonging to the default locale is updated, all of its siblings are marked as pending review.
  • When deleting an entry, if it belongs to the default locale its translations will also be deleted.

Model attributes translation

You can also use the translation management system to manage your model attributes translations. To do this, you only need to:

  • Make sure either the database or mixed source are set.
  • Make sure your models use the Waavi\Translation\Translatable\Trait
  • In your model, add a translatableAttributes array with the names of the attributes you wish to be available for translation.
  • For every field you wish to translate, make sure there is a corresponding attributeName_translation field in your database.

Example:

	\Schema::create('examples', function ($table) {
        $table->increments('id');
        $table->string('slug')->nullable();
        $table->string('title')->nullable();
        $table->string('title_translation')->nullable();
        $table->string('text')->nullable();
        $table->string('text_translation')->nullable();
        $table->timestamps();
    });

    class Example extends Model
	{
	    use \Waavi\Translation\Traits\Translatable;
	    protected $translatableAttributes = ['title', 'text'];
	}

Uri localization

You may use Waavi\Translation\Middleware\TranslationMiddleware to make sure all of your urls are properly localized. The TranslationMiddleware will only redirect GET requests that do not have a locale in them.

For example, if a user visits the url /home, the following would happen:

  • The middleware will check if a locale is present.
  • If a valid locale is present:
    • it will globally set the language for that locale
    • the following data will be available in your views:
      • currentLanguage: current selected Language instance.
      • selectableLanguages: list of all languages the visitor can switch to (except the current one)
      • altLocalizedUrls: a list of all localized urls for the current resource except this one, formatted as ['locale' => 'en', 'name' => 'English', 'url' => '/en/home']
  • If no locale is present:
    • Check the first two letters of the brower's accepted locale HTTP_ACCEPT_LANGUAGE (for example 'en-us' => 'en')
    • If this is a valid locale, redirect the visitor to that locale => /es/home
    • If not, redirect to default locale => /en/home
    • Redirects will keep input data in the url, if any

You may choose to activate this Middleware globally by adding the middleware to your App\Http\Kernel file:

	protected $middleware = [
		/* ... */
        \Waavi\Translation\Middleware\TranslationMiddleware::class,
    ]

Or to apply it selectively through the 'localize' route middleware, which is already registered when installing the package through the ServiceProvider.

It is recommended you add the following alias to your config/app.php aliases:

	'aliases'         => [
		/* ... */
		'UriLocalizer'	=> Waavi\Translation\Facades\UriLocalizer::class,
    ];

Every localized route must be prefixed with the current locale:

	// If the middleware is globally applied:
	Route::group(['prefix' => \UriLocalizer::localeFromRequest()], function(){
		/* Your routes here */
	});

	// For selectively chosen routes:
	Route::group(['prefix' => \UriLocalizer::localeFromRequest(), 'middleware' => 'localize')], function () {
	    /* Your routes here */
	});

Starting on v2.1.6, you may also specify a custom position for the locale segment in your url. For example, if the locale info is the third segment in a URL (/api/v1/es/my_resource), you may use:

    // For selectively chosen routes:
    Route::group(['prefix' => 'api/v1'], function() {
        /** ... Non localized urls here **/

        Route::group(['prefix' => \UriLocalizer::localeFromRequest(2), 'middleware' => 'localize:2')], function () {
            /* Your localized routes here */
        });
    });

In your views, for routes where the Middleware is active, you may present the user with a menu to switch from the current language to another by using the shared variables. For example:

<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ $currentLanguage->name }} <b class="caret"></b></a>
    <ul class="dropdown-menu">
        @foreach ($altLocalizedUrls as $alt)
            <li><a href="{{ $alt['url'] }}" hreflang="{{ $alt['locale'] }}">{{ $alt['name'] }}</a></li>
        @endforeach
    </ul>
</li>

translation's People

Contributors

al0mie avatar alexhouse avatar alexregenbogen avatar anderslal avatar aymanelarian avatar balakir avatar divdax avatar dmitryuk avatar dylian94 avatar lysz210 avatar makstech avatar markredeman avatar michail1982 avatar mortezapoussaneh avatar ngima avatar ockle avatar saji89 avatar sildraug avatar thku avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

translation's Issues

Non-static method Waavi\Translation\Repositories\LanguageRepository::findByLocale() should not be called statically, assuming $this from incompatible context

I run this code in my controller

Top of my controller

use Waavi\Translation\Repositories\LanguageRepository;
use Waavi\Translation\Repositories\TranslationRepository;

function that runs

public function give(){
$language = LanguageRepository::findByLocale(1);
}

it says

Non-static method Waavi\Translation\Repositories\LanguageRepository::findByLocale() should not be called statically, assuming $this from incompatible context.

option to change between files / database precedence [improvement]

Hi,

Actually the documentation say entries found in the filesystem take precedence over the database. It should be nice to inverse this spec because living translations should be in database but the application need default values in files.

And perhaps changing between behaviors with an configuration option ;-)

Cheers.

[L5.2] Call to undefined method ...\Facades\UriLocalizer::localeFromRequest()

Hi,

I followed the doc to configuring Waavi\Translation but got a problem with the UriLocalizer facade.

  • "laravel/framework": "5.2.22"
  • "waavi/translation": "2.1.4"

The code

Route::group(['prefix' => \UriLocalizer::localeFromRequest()], function(){
...

thrown the Exception:

FatalErrorException in Facade.php line 215: Call to undefined method Waavi\Translation\Facades\UriLocalizer::localeFromRequest()

I do not understand the error because of course, the Facade & Service exists. So why it does not found the well defined method localeFromRequest() ??

I'm lost...

Cheers, Cyrille.

Dots in translations

Hello. I use your extension translation and my translations have dots.

Example:

    'product' => 'Товар',
    'products' => 'Товары',
    'products.control' => 'Управление товарами',
    'products.all' => 'Все товары',
    'products.create' => 'Создать товар',
    'products.add' => 'Добавить товар',
    'products.edit' => 'Редактировать товар',
    'products.update' => 'Обновить товар',
    'products.delete' => ' Удалить товар',
    'products.file_help' => 'Добавить файлы к товару'

In test environment I used the driver files. After that, I switched the driver to database and an error occurred.

This query: https://github.com/Waavi/translation/blob/master/src/Repositories/TranslationRepository.php#L235 return all records but collection method reduce use array_set.

Function array_set use dot for specific purposes: https://github.com/illuminate/support/blob/1dfbb0f868606744f84887c805b503fbfe3bef8f/Arr.php#L434

Therefore, the result trans('shop.products') returns an array and {{ trans('shop.products') }} is trying to echo array that causes the error.

[L5.2] Maximum function nesting level of '100' reached, aborting

Hi,
I try to integrate Waavi/translation in a Laravel 5.2 simple project.

  • "laravel/framework": "5.2.22"
  • "waavi/translation": "2.1.4"

I did migration and vendor:publish.

In config/translator.php:

    'source'            => env('TRANSLATION_SOURCE', 'mixed'),
    'available_locales' => ['en','fr'],
    'cache'             => [
        'enabled' => env('TRANSLATION_CACHE_ENABLED', false),
        'timeout' => env('TRANSLATION_CACHE_TIMEOUT', 60),
        'suffix'  => env('TRANSLATION_CACHE_SUFFIX', 'translation'),
    ],

In config/app.php:

   ...
    'providers' => [
        ...
        // Replace Translation service provider 
        //Illuminate\Translation\TranslationServiceProvider::class,
        Waavi\Translation\TranslationServiceProvider::class,
        ...
    ],

Then when when loading pages in route with Laravel default 'web' middleware a FatalException occurs.

Fatal error:  Maximum function nesting level of '100' reached, aborting! in .../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 702
Stack trace:
  1. {main}() .../public/index.php:0
  2. Illuminate\Foundation\Http\Kernel->handle() .../public/index.php:54
  3. Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter() .../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:99
  4. Illuminate\Pipeline\Pipeline->then() .../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:132
  5. call_user_func() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103
  6. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103
  7. call_user_func() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32
  8. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32
  9. call_user_func_array() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124
 10. Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124
 11. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() .../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:44
 12. call_user_func() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:52
 13. Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:52
 14. Illuminate\Routing\Router->dispatch() .../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:246
 15. Illuminate\Routing\Router->dispatchToRoute() .../vendor/laravel/framework/src/Illuminate/Routing/Router.php:675
 16. Illuminate\Routing\Router->runRouteWithinStack() .../vendor/laravel/framework/src/Illuminate/Routing/Router.php:699
 17. Illuminate\Pipeline\Pipeline->then() .../vendor/laravel/framework/src/Illuminate/Routing/Router.php:726
 18. call_user_func() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103
 19. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103
 20. call_user_func() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32
 21. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32
 22. call_user_func_array() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124
 23. Illuminate\Cookie\Middleware\EncryptCookies->handle() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124
 24. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() .../vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:59
 25. call_user_func() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32
 26. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32
 27. call_user_func_array() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124
 28. Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124
 29. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() .../vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37
 30. call_user_func() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32
 31. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32
 32. call_user_func_array() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124
 33. Illuminate\Session\Middleware\StartSession->handle() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124
 34. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() .../vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:62
 35. call_user_func() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32
 36. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32
 37. call_user_func_array() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124
 38. Illuminate\View\Middleware\ShareErrorsFromSession->handle() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124
 39. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() .../vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php:49
 40. call_user_func() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32
 41. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32
 42. call_user_func_array() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124
 43. Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124
 44. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() .../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:64
 45. call_user_func() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:52
 46. Illuminate\Routing\Router->Illuminate\Routing\{closure}() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:52
 47. Illuminate\Routing\Route->run() .../vendor/laravel/framework/src/Illuminate/Routing/Router.php:724
 48. Illuminate\Routing\Route->runController() .../vendor/laravel/framework/src/Illuminate/Routing/Route.php:140
 49. Illuminate\Routing\ControllerDispatcher->dispatch() .../vendor/laravel/framework/src/Illuminate/Routing/Route.php:174
 50. Illuminate\Routing\ControllerDispatcher->callWithinStack() .../vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:54
 51. Illuminate\Pipeline\Pipeline->then() .../vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:96
 52. call_user_func() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103
 53. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() .../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103
 54. call_user_func() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:52
 55. Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}() .../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:52
 56. Illuminate\Routing\Router->prepareResponse() .../vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:95
 57. Symfony\Component\HttpFoundation\Response->__construct() .../vendor/laravel/framework/src/Illuminate/Routing/Router.php:1087
 58. Illuminate\Http\Response->setContent() .../vendor/symfony/http-foundation/Response.php:199
 59. Illuminate\View\View->render() .../vendor/laravel/framework/src/Illuminate/Http/Response.php:53
 60. Illuminate\View\View->renderContents() .../vendor/laravel/framework/src/Illuminate/View/View.php:83
 61. Illuminate\View\View->getContents() .../vendor/laravel/framework/src/Illuminate/View/View.php:118
 62. Illuminate\View\Engines\CompilerEngine->get() .../vendor/laravel/framework/src/Illuminate/View/View.php:147
 63. Illuminate\View\Engines\PhpEngine->evaluatePath() .../vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php:59
 64. include() .../vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php:42
 65. trans() .../storage/framework/views/1c01d6b654b11602ddeef39c984e07d71910483f.php:15
 66. app() .../vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:700
 67. Illuminate\Foundation\Application->make() .../vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:105
 68. Illuminate\Foundation\Application->loadDeferredProvider() .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php:671
 69. Illuminate\Foundation\Application->registerDeferredProvider() .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php:628
 70. Illuminate\Foundation\Application->register() .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php:648
 71. Waavi\Translation\TranslationServiceProvider->register() .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php:531
 72. Waavi\Translation\TranslationServiceProvider->registerFileLoader() .../vendor/waavi/translation/src/TranslationServiceProvider.php:46
 73. Illuminate\Foundation\Application->make() .../vendor/waavi/translation/src/TranslationServiceProvider.php:112
 74. Illuminate\Container\Container->make() .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php:674
 75. Illuminate\Container\Container->build() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:633
 76. Illuminate\Container\Container->getDependencies() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:779
 77. Illuminate\Container\Container->resolveClass() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:808
 78. Illuminate\Foundation\Application->make() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:853
 79. Illuminate\Container\Container->make() .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php:674
 80. Illuminate\Container\Container->build() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:633
 81. Illuminate\Validation\ValidationServiceProvider->Illuminate\Validation\{closure}() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:735
 82. Illuminate\Container\Container->offsetGet() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:36
 83. Illuminate\Foundation\Application->make() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:1178
 84. Illuminate\Container\Container->make() .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php:674
 85. Illuminate\Container\Container->build() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:633
 86. Illuminate\Translation\TranslationServiceProvider->Illuminate\Translation\{closure}() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:735
 87. Illuminate\Container\Container->offsetGet() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:26
 88. Illuminate\Foundation\Application->make() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:1178
 89. Illuminate\Foundation\Application->loadDeferredProvider() .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php:671
 90. Illuminate\Foundation\Application->registerDeferredProvider() .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php:628
 91. Illuminate\Foundation\Application->register() .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php:648
 92. Waavi\Translation\TranslationServiceProvider->register() .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php:531
 93. Illuminate\Translation\TranslationServiceProvider->register() .../vendor/waavi/translation/src/TranslationServiceProvider.php:44
 94. Waavi\Translation\TranslationServiceProvider->registerLoader() .../vendor/laravel/framework/src/Illuminate/Translation/TranslationServiceProvider.php:23
 95. Illuminate\Container\Container->singleton() .../vendor/waavi/translation/src/TranslationServiceProvider.php:87
 96. Illuminate\Container\Container->bind() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:271
 97. Illuminate\Container\Container->resolved() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:213
 98. Illuminate\Container\Container->isAlias() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:151
 99. Illuminate\Container\Container->normalize() .../vendor/laravel/framework/src/Illuminate/Container/Container.php:166

Load language file in folders recursively

How can I add the possibility to load language files recursively, lets assume that in my language folder I have another folder like /users or /posts and i want to load those files to the database and retrieve them later
I have not gone deep in the code but i believe it should not be difficult, anyway, I´ll apreciate the help...
rjrg1989

get an entry by locale, group and item

I need to be able to get an entry by locale, group and item. I need this so when I am viewing the pending entries I can show the english version of entry so that reviewer can see what has changed and be able to correctly update the pending entry.

Waavi\Translation\TranslationServiceProvider:register() being called multiple times.

First of all thanks for your thoughtful package, it's the most comprehensive solution I've found on the web so far.

But if you are aware of my reply on another issue, I've somehow resolved the "ReflectionException" problem caused by a malformed bootstrap/cache/services.php. And during my time with the debugger, I've discovered that register() of TranslationServiceProvider was being called multiple times, apparently doing the exact same thing 2 - 3 times over, and I think this could lead to some performance issues.

Firstly before I've added that publishes() method to the ServiceProvider, I've got 2 repeated calls on register(), and after I've added that, I've got 3 calls.

I've actually skimmed though the call stack from the debugger, the subsequent repeated calls were invoked by the "Validator" (via some getDependencies() method) as I was tracing it during the "out of the box" authentication.

I'm not 100% sure about this, but it looks like some other providers depend on the original "translator" service (the service name being used everywhere I believe), and when they invoke that, since it now points to your provider, it re-does everything from start to end (translator, translation.loader, translation.cache.repositories), so this may explain why it's 3 calls (wild guess).

So is there any official way to avoid this redundant instantiation? I've also noticed within the Laravel Container, somewhere it checks for already-instantiated instances, could it be a "missed registration" that causes Laravel to re-instantiate your service provider over again? I could be all wrong so please forgive me guesses.

Sorry I was busy on stuff so I haven't yet gotten to the bottom of the stack trace, but I hope to contribute some input on this matter. Thanks for your inspiring package again.

I'll do some more stack tracing when free.

Load command for DB -> files

I know there is a command to load the translation files in to the database, but is it possible to facilitate a way to do it the other way around? I.e.; generate language files from a database?

The scenario for this is that I currently have a web app with 2 environments; 1 for translators to test their stuff and 1 production. Ideally, I want to generate the files for production and not install the Waavi/translation package there at all, saving some overhead.

Can't get locales from translator.php config file

I think there's a naming mismatch between the config file and LanguageRepository->availableLocales().

In translator.php the available locales key is named available_locales, while in LanguageRepository (line 129-130-134) the code tries to access translator.locales.

Laravel 5 support?

Hi! Your language package seems to be great! Will you add support for Laravel 5 now that the code appears stable and about to be released? Would be awesome.

[L 5.1] Undefined Variable on middleware view shared variables

error:

at HandleExceptions->handleError('8', 'Undefined variable: currentLanguage', '/home/vagrant/dev/translateapp/app/Http/routes.php', '16', array()) in routes.php line 16

this is my route.php

$localizer = \App::make(\Waavi\Translation\UriLocalizer::class); // temp fix

Route::group(['prefix' => $localizer->localeFromRequest()], function(){
        get('/', 'HomepageController@index');
    });

I get that error. But i already had add to the global $middleware array in kernel for \Waavi\Translation\Middleware\TranslationMiddleware::class,

any solutions?

Javascript localization

do you have options like putting translation also in the javascript? ex. trans.messages.Hello?

Translation for nested array message

Hello, I was using database mode of your translation. I checked that in validation file, there are some messages which are written in nested array; like in between validation message, numeric message is written in nested array. How can we store this kind of messages in database? Can you please help me?

translator:load doesn't work?

Everything install perfectly, but when I run the command php artisan translator:load, it shows nothing and nothing is inserted in the database. I've added two languages before hand (english/french).

Not sure what could be the issue. This package seems perfect for what I need, if you could help me out that would be amazing!

Thanks!

EDIT: Figured it out. In the file:
Vendor/Waavi/model/translation/src/Waavi/Translation/Commands/FileLoaderCommand.php, I changed:

$this->path = app_path().'/lang';

to

$this->path = app_path().'\lang';

and

$locale = str_replace($this->path.'/', '', $localeDir);

to

$locale = str_replace($this->path.'\', '', $localeDir);

It was searching for files like this:

C:\Program Files (x86)\Ampps\www\www.website.dev\app/lang\en

So modifying the paths to backslash worked perfect.

Thanks so much for the package!!

Segmentation fault

Hi,
When i want to load my translations into the database i'm getting this strange error:

php artisan translator:load --env=local
Segmentation fault: 11

How can i fix this?

More consistent namespace for UriLocalizer.

Only the UriLocalizer is not following the package's naming convention. I propose to change it to "translation.uri.localizer", and the respective Facade can handle the Name->Instance-Name translation.

public function register()
{
    $this->mergeConfigFrom(__DIR__ . '/../config/translator.php', 'translator');

    parent::register();
    $this->registerCacheRepository();
    $this->registerFileLoader();
    $this->registerCacheFlusher();
    $this->app->singleton('translation.uri.localizer', UriLocalizer::class);
    $this->app[\Illuminate\Routing\Router::class]->middleware('localize', TranslationMiddleware::class);
    // Fix issue with laravel prepending the locale to localize resource routes:
    $this->app->bind('Illuminate\Routing\ResourceRegistrar', ResourceRegistrar::class);
}

protected static function getFacadeAccessor()
{
    return 'translation.uri.localizer';
}

With these, the package's namespace would be consistent inside the bootstrap/cache/services.php

'translator' => 'App\\Providers\\TranslationServiceProvider',
'translation.loader' => 'App\\Providers\\TranslationServiceProvider',
'translation.cache.repository' => 'App\\Providers\\TranslationServiceProvider',
'translation.uri.localizer' => 'App\\Providers\\TranslationServiceProvider',

Or whatever name you choose that exhibits a more consistent convention, it'd be great!

Support databases other than MySQL

Wanted to use this with PostgreSQL and realized it only works with MySQL because of the DB::statement in create_language_entries_table migration.

This should work just fine:

$table->unique(array('language_id', 'namespace', 'group', 'item'));

Also, isn't InnoDB the default storage engine?

Mixing Waavi/translation with authentication controllers (Login & Register)

Hi Guys, first thing is I'm new to Laravel. I did install Waavi/translation to my Laravel project it's working and redirects "laravel.dev:8000/en", but the route part is not working for me. I mean this part.

 // If the middleware is globally applied:
    Route::group(['prefix' => \UriLocalizer::localeFromRequest()], function(){
        /* Your routes here */
    });

    // For selectively chosen routes:
    Route::group(['prefix' => \UriLocalizer::localeFromRequest(), 'middleware' => 'localize')], function () {
        /* Your routes here */
    });

It gives me this error:

Class 'UriLocalizer' not found

And after many trying I could fix it with Laravel's locale like that:

Route::get('/{locale}', function () {
    return view('welcome');
});

or like that:
Route::get('/{locale}/home', 'HomeController@index');

so where am I doing wrong? Is there anything I should do or change on this part:

 // If the middleware is globally applied:
    Route::group(['prefix' => \UriLocalizer::localeFromRequest()], function(){
        /* Your routes here */
    });

    // For selectively chosen routes:
    Route::group(['prefix' => \UriLocalizer::localeFromRequest(), 'middleware' => 'localize')], function () {
        /* Your routes here */
    });

and my real question is, How can I mix it with Laravel's default login system. I mean this:
Auth::routes();
I tried like that but it's not working:
Auth::routes('/{locale});

because now when I go to "http://laravel.dev:8000/en/login" it gives me this error:

NotFoundHttpException in RouteCollection.php line 161:

PS: I'm using Laravel 5.3

Server didn't response when using translations in blade templates

Install last version (2.1.7) today, update settings, move translations to database (all moved fine), but when I try to use {{ trans('messsage') }} in blade template - page didn't response at all and get 504 Gateway Time-out error at the end. Maybe, you have an idea what it could be? I use Laravel framework v.5.3.22 Thanks!)

Priority in mixed driver

Hello.
Are you going to provide an ability to change the priority in driver mixed so that the choose priority will be for database?

Segment fault after updating to laravel 4.2

After installing the package on Laravel 4.2, none of my blade views were being displayed. Turns out that the server was throwing a apache segment fault. After removing waavi tranlation, everything came back to normal. Used the same package on older version of Laravel and never had any problem.

Not sure if this is just me, only had this issue in one project.

Exception when loading validation.php into db

When processing lang files with php artisan translator:load i get this error:

[ErrorException]
preg_replace(): Parameter mismatch, pattern is a string while replacement is an array

I presume problem is in nested array values. How can i fix this?

return [
'accepted'             => 'The :attribute must be accepted.',
    'active_url'           => 'The :attribute is not a valid URL.',
    'after'                => 'The :attribute must be a date after :date.',
    'alpha'                => 'The :attribute may only contain letters.',
    'alpha_dash'           => 'The :attribute may only contain letters, numbers, and dashes.',
    'alpha_num'            => 'The :attribute may only contain letters and numbers.',
    'array'                => 'The :attribute must be an array.',
    'before'               => 'The :attribute must be a date before :date.',
    'between'              => [
        'numeric' => 'The :attribute must be between :min and :max.',
        'file'    => 'The :attribute must be between :min and :max kilobytes.',
        'string'  => 'The :attribute must be between :min and :max characters.',
        'array'   => 'The :attribute must have between :min and :max items.',
    ],
....
custom' => [
        'email' => [
            'required' => 'The Email field is required.',
            'email' => 'Email must be a valid email address.',
        ],
    ],

'attributes' => [],
];

Migrations don't work

When trying to run default package migrations i get this error

php artisan migrate --package=waavi/translation

[Exception]                                                                  
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t  
oo long; max key length is 1000 bytes (SQL: alter table `language_entries`   
add unique language_entries_language_id_namespace_group_item_unique(`langua  
ge_id`, `namespace`, `group`, `item`)) (Bindings: array (                    
))                                                                           

[PDOException]                                                               
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t  
oo long; max key length is 1000 bytes            

[L 5.2] locale prefix not detected

The browser is correctly redirected (e.g. /en) but laravel throws an NotFoundHttpException error. Maybe I just did a misconfiguration, but \Log::debug($localizer->localeFromRequest()) returns an empty value.

routes.php

// bug fix for Waavi…::localeFromRequest() problem
$localizer = \App::make(\Waavi\Translation\UriLocalizer::class);

Route::group(['prefix' => $localizer->localeFromRequest(), 'middleware' => 'web'], function () {
    Route::get('/', function () {
        return view('welcome');
     });
});

I added the localize middleware to the web middleware group.
As soon as I change the following

Repositories/LanguageRepository.php

/**
 *  Returns a list of all available locales.
 *
 *  @return array
 */
public function availableLocales()
{
    /*if ($this->config->has('translator.locales')) {
        return $this->config->get('translator.locales');
    }
    if ($this->tableExists()) {
        $locales = $this->model->distinct()->get()->lists('locale')->toArray();
        $this->config->set('translator.locales', $locales);
        return $locales;
    }*/
    return $this->defaultAvailableLocales;
}

Everything seems to work…

Locales > 6 characters aren't allowed

In the database migration script, the locale is limited to 6 characters. This prevents some locales from being used properly, ie, "mn-Mong", "zh-Hant".

Settings App::locale

When using the URI Localization the app locale is not set in the middleware. Only the translator locale is set. When using the URI Localization as locale determination it would be nice to set the App locale in the middleware.

I fixed this issue for a current application by setting the app locale in the main controller
public function __construct(Translator $translator) { App::setLocale($translator->locale()); }

Fails on 'attributes' key?

This seems to fail on the following at the bottom of resources/lang/en/validation.php when running translator:load:

/*
|--------------------------------------------------------------------------
| Custom Validation Attributes
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
| with something more reader friendly such as E-Mail Address instead
| of "email". This simply helps us make messages a little cleaner.
|
*/

'attributes' => [],

The value 'Array' is inserted into the database for this key and the following error is thrown:

[ErrorException]                                                                       
preg_replace(): Parameter mismatch, pattern is a string while replacement is an array 

Of course, this value can just be removed, but if this is included by default it seems as though it should be able to be handled?

"Class translation.uri.localizer does not exist" using UriLocalizer in route prefix

I am trying to add this translation package to an existing Laravel 5.2 project. I was previously using a different package for localizing just URIs (Laravel Localization) but removed it before installing the Waavi translation package. After installing and configuring this package, and adding 'prefix' => UriLocalizer::localeFromRequest() to my routes, an exception is thrown with the following error:

ReflectionException in Container.php line 738:
Class translation.uri.localizer does not exist

While attempting to debug the problem I found that when Laravel compiles the manifest of service providers, it creates deferred services for translator and translation.loader because these are in the array returned by the provides() method that the Waavi TranslationServiceProvider inherits from LaravelTranslationServiceProvider. But the string translation.uri.localizer doesn't appear anywhere in my bootstrap/cache/services.php file, even after manually deleting it to force a recompilation.

It seems as if the exception is being thrown before the register() method of your TranslationServiceProvider is being called, which might be part of the problem, I'm not sure.

Please let me know what else I can try, or what other information/tests would be helpful to resolve this issue. Your translation package looks great, and I'd love to be able to start using it. Thanks!

Waavi/translation could not be found in any version

when I run composer update there is error throwing back.

The requested package waavi/translation could not be found in any version, there may be a typo in the package name.

and I copied the the package name from git hub...

    "require": {
        .
        .
        .
        "waavi/translation": "*"
    },

I also imported :

    "repositories": [
        {
            "type": "vcs",
            "url":  "[email protected]:Waavi/translation.git"
        }
    ],

Problem translating attributes

Got this in my translation file (validation.php):

'attributes' => [
        'nick' => 'Nickname',
        'passwd' => 'Passwort',
],

this is imported in my database:
group: validation item: attributes.nick

But in my error messages its not resolved. Is there an error on my side or are attribute translations not supported?

translator:load doesn't load translations to db

Hi,

I have the same problem as decsribed here #9, locally (EasyPhp) an on the server (apache). Languages are defined in the languages table and I have the version with DIRECTORY_SEPARATOR. In the cache table, I have for example a key like this "laravelwaavi|translation|fr.nav.*", so I suppose that the package finds the translation files!?

I tried with debug on/off, different cache types, one language with one file...

I don't know really what else I could provide to help

Breaking change in 2.1.4.10

If the repo is following the semantic versioning then commit 97bfbc3 should be considered a breaking change. The commit breaks apps that use locale in the session differently than a string.

For example I have an app which we place a locale object in the session and not the string. This breaks our app because our app expects an object, but a string is placed automatically by the commit mentioned above.

An if conditional could be added on line 72 for b6e24d5 checking for a config which would tell the TranslationMiddleware whether or not to set the locale.

Unable to translate text to another language

Hi. I am using Laravel 5.1. i just installed the waavi package and tried with the translation. But it seems that my text is unable to translate to another language other then the default english. On my blade file i did this {{ trans('messages.member login') }}. when the page is loaded, i saw this Member Login which is correct. But when i tried to switch to locale 'zh_cn' the text should change to it chinese text. the chinese text has already being entered into the DB. when user tried to switch langauge i put the locale into a Session like this Session::put('locale', 'zh_cn').
is this wrong?
if wrong how do i swap the locale for the chinese text to be shown?

my config/translator.php looks like this

return [

    /*
    |--------------------------------------------------------------------------
    | Default Translation Mode
    |--------------------------------------------------------------------------
    |
    | This option controls the translation's bundle mode of operation.
    |
    | Supported:
    |
    |   'mixed'         Both files and the database are queried for language entries, with files taking priority.
    |   'database'      Use the database as the exclusive source for language entries.
    |   'files'         Use files as the exclusive source for language entries [Laravel's default].
     */
    'source'            => 'database',

    // In case the files source is selected, please enter here the supported locales for your app.
    // Ex: ['en', 'es', 'fr']
    'available_locales' => ['en', 'zh_cn'],

    /*
    |--------------------------------------------------------------------------
    | Default Translation Cache
    |--------------------------------------------------------------------------
    |
    | Choose whether to leverage Laravel's cache module and how to do so.
    |
    |   'enabled'       Boolean value.
    |   'timeout'       In minutes.
    |
     */
    'cache'             => [
        'enabled' => env('TRANSLATION_CACHE_ENABLED', true),
        'timeout' => env('TRANSLATION_CACHE_TIMEOUT', 60),
        'suffix'  => env('TRANSLATION_CACHE_SUFFIX', 'translation'),
    ],
];

It's not possible to edit other attributes of translation

Hi,

first of all, great package, really enjoying it in our product.

I was wondering, why don't the TranslationRepository methods update() and updateAndLock() accept $attributes array similar to LanguageRepository. Only accepting $id and $text makes it impossible for the user to update stuff like namespace etc.

Maybe I misunderstood the purpose of it, anyhow, it got me wondering.

Thanks!

Always direct back to default locale while go to another page

Hi, I am using laravel 5.2. I did follow all yours document to implement translation feature. But I got an issue, lets say current my url is "something.com/zh/about", when I click to another page it will return back to default locale which is like "something.com/en/gallery". Is there any more setting I need to configure or anything I did wrong?
Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.