Home > database >  What can prevent localization from working properly?
What can prevent localization from working properly?

Time:11-03

Very basic setup:

config/app.php:

'locale' => 'de',

routes/web.php:

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

resources/views/test.blade.php:

{{ app()->getLocale() }}
{{ __('Test material') }}

lang/de.json:

{
    "Test material": "Testmaterial"
}

If I launch this in my app, I get:

de Test material

but I expect to see

de Testmaterial

If I add all provided code in a fresh laravel installation, it is working as expected. In my app it is not and I am completely lost to find a place where I can look for an potential issue.

What I tried:

grep -r "Test material" .
./resources/views/test.blade.php:{{ __('Test material') }}
./lang/de.json:    "Test material": "Testmaterial"

to find duplicate keys, but there are none. This is my folder structure of lang:

├── de.json
└── en
    ├── auth.php
    ├── pagination.php
    ├── passwords.php
    └── validation.php

What could prevent my translation from working?

CodePudding user response:

Your file is not on the correct place. It should be on resources/lang/de.json

  • Related