|
5 | 5 | use App\Command\Hello;
|
6 | 6 | use App\ViewInjection\CommonViewInjection;
|
7 | 7 | use App\ViewInjection\LayoutViewInjection;
|
| 8 | +use App\ViewInjection\TranslatorViewInjection; |
8 | 9 | use Yiisoft\Definitions\Reference;
|
9 | 10 | use Yiisoft\ErrorHandler\Middleware\ErrorCatcher;
|
10 | 11 | use Yiisoft\Router\Middleware\Router;
|
11 | 12 | use Yiisoft\Session\SessionMiddleware;
|
| 13 | +use Yiisoft\Yii\Middleware\Locale; |
12 | 14 | use Yiisoft\Yii\View\CsrfViewInjection;
|
13 | 15 |
|
14 | 16 | return [
|
|
17 | 19 | 'locale' => 'en',
|
18 | 20 | 'name' => 'My Project',
|
19 | 21 | ],
|
| 22 | + 'locale' => [ |
| 23 | + 'locales' => ['en' => 'en-US', 'ru' => 'ru-RU'], |
| 24 | + 'ignoredRequests' => [ |
| 25 | + '/debug**', |
| 26 | + ], |
| 27 | + ], |
20 | 28 | 'middlewares' => [
|
21 | 29 | ErrorCatcher::class,
|
22 | 30 | SessionMiddleware::class,
|
| 31 | + Locale::class, |
23 | 32 | Router::class,
|
24 | 33 | ],
|
25 | 34 |
|
|
29 | 38 | '@assets' => '@root/public/assets',
|
30 | 39 | '@assetsUrl' => '@baseUrl/assets',
|
31 | 40 | '@baseUrl' => '/',
|
32 |
| - '@message' => '@root/resources/message', |
| 41 | + '@messages' => '@resources/messages', |
33 | 42 | '@npm' => '@root/node_modules',
|
34 | 43 | '@public' => '@root/public',
|
35 | 44 | '@resources' => '@root/resources',
|
|
40 | 49 | ],
|
41 | 50 | ],
|
42 | 51 |
|
| 52 | + 'yiisoft/translator' => [ |
| 53 | + 'locale' => 'en', |
| 54 | + 'fallbackLocale' => 'en', |
| 55 | + 'defaultCategory' => 'app', |
| 56 | + 'categorySources' => [ |
| 57 | + // You can add categories from your application and additional modules using `Reference::to` below |
| 58 | + // Reference::to(ApplicationCategorySource::class), |
| 59 | + Reference::to('translation.app'), |
| 60 | + ], |
| 61 | + ], |
| 62 | + |
43 | 63 | 'yiisoft/yii-view' => [
|
44 | 64 | 'injections' => [
|
45 | 65 | Reference::to(CommonViewInjection::class),
|
46 | 66 | Reference::to(CsrfViewInjection::class),
|
47 | 67 | Reference::to(LayoutViewInjection::class),
|
| 68 | + Reference::to(TranslatorViewInjection::class), |
48 | 69 | ],
|
49 | 70 | ],
|
50 | 71 |
|
|
0 commit comments