Closed mafftor closed 4 years ago
Okay, I've solved the problem like:
copied boot method from package and created custom service provider
class TranslationManagerServiceProvider extends ManagerServiceProvider
{
/**
* Bootstrap the application events.
*
* @param Router $router
* @return void
*/
public function boot(Router $router)
{
$viewPath = __DIR__ . '/../resources/views';
$this->loadViewsFrom($viewPath, 'translation-manager');
$this->publishes([
$viewPath => base_path('resources/views/vendor/translation-manager'),
], 'views');
$migrationPath = __DIR__ . '/../database/migrations';
$this->publishes([
$migrationPath => base_path('database/migrations'),
], 'migrations');
$config = $this->app['config']->get('translation-manager.route', []);
$config['namespace'] = 'Barryvdh\TranslationManager';
+ $config['prefix'] = LaravelLocalization::setLocale() . '/' . $config['prefix'];
$router->group($config, function ($router) {
$router->get('view/{groupKey?}', 'Controller@getView')->where('groupKey', '.*');
+ $router->get('settings', '\App\Http\Controllers\Admin\TranslationController@settings')->name('translations.settings');
$router->get('/{groupKey?}', 'Controller@getIndex')->where('groupKey', '.*');
$router->post('/add/{groupKey}', 'Controller@postAdd')->where('groupKey', '.*');
$router->post('/edit/{groupKey}', 'Controller@postEdit')->where('groupKey', '.*');
$router->post('/groups/add', 'Controller@postAddGroup');
$router->post('/delete/{groupKey}/{translationKey}', 'Controller@postDelete')->where('groupKey', '.*');
$router->post('/import', 'Controller@postImport');
$router->post('/find', 'Controller@postFind');
$router->post('/locales/add', 'Controller@postAddLocale');
$router->post('/locales/remove', 'Controller@postRemoveLocale');
$router->post('/publish/{groupKey}', 'Controller@postPublish')->where('groupKey', '.*');
$router->post('/translate-missing', 'Controller@postTranslateMissing');
});
}
}
Register new ServiceProvider in config/app.php
Don't forget write in composer.json
"extra": {
"laravel": {
"dont-discover": [
+ "barryvdh/laravel-translation-manager"
]
}
},
Signed + where I added new lines!
Sadly abandoned repo :(
Hello there! I need to use dynamical route prefix but I can't use any executive code inside config file.
I use mcamara/laravel-localization and it must be implemented like:
As you know, barryvdh/laravel-translation-manager register its own routes in boot method and gets route's config.
I tried to do something like this: but I don't know where I should use this code. The routes already registered and nothing changes
P.S. I have to get a prefix: {lang}/translations {lang} - [en|fr|de]
Thanks in advance!