Giter Club home page Giter Club logo

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

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?

Javascript localization

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

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?

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

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()); }

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.

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' => [],
];

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.

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            

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"
        }
    ],

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.

[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?

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.

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!

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 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

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.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…

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.

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

[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

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!!

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.

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!)

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".

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!

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

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?

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'),
    ],
];

[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.

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.

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?

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?

"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!

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.

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?

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.