0

Relevant configuration : Php version 8 - laravel 8.

I have been trying to use laravel json translation without success and I don't understand how to make it work. The normal way using shorkeys works just fine as shown in the output below (pictures).

dashboard.blade.php :

<x-app-layout>

<x-slot name="header">
    <h2 class="font-semibold text-xl text-gray-800 leading-tight">
        {{ __('Dashboard') }}
    </h2>
</x-slot>

<div class="py-12">
    <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
        <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
            <div class="p-6 bg-white border-b border-gray-200">
                You're logged in! {{ app()->getLocale() ." : " . __('30 Days') }}
            </div>
            <div class="p-6 bg-white border-b border-gray-200">
                You're logged in! {{ app()->getLocale() ." : " . trans('30 Days') }}
            </div>
            <div class="p-6 bg-white border-b border-gray-200">
                You're logged in! {{ app()->getLocale() ." : " . Lang::get('30 Days') }}
            </div>
            <div class="p-6 bg-white border-b border-gray-200">
                You're logged in! {{ app()->getLocale() ." : " . __('auth.failed') }}
            </div>
            <div class="p-6 bg-white border-b border-gray-200">
                You're logged in! {{ app()->getLocale() ." : " . trans('auth.failed') }}
            </div>
            <div class="p-6 bg-white border-b border-gray-200">
                You're logged in! {{ app()->getLocale() ." : " . Lang::get('auth.failed') }}
            </div>
        </div>
    </div>
</div>

auth.php :

return [
    'failed'   => 'Diese Kombination aus Zugangsdaten wurde nicht in unserer Datenbank gefunden.',
    'password' => 'Das eingegebene Passwort ist nicht korrekt.',
    'throttle' => 'Zu viele Loginversuche. Versuchen Sie es bitte in :seconds Sekunden nochmal.',
];

de.json :

{
    "30 Days": "30 Tage",
    "60 Days": "60 Tage",
    "90 Days": "90 Tage",
    ":amount Total": ":amount Gesamt",
    ...rest of the translations,
}
  • en locale
  • de locale
coderdonezo
  • 399
  • 1
  • 12
  • Have you made the check at config/app.php ? – Kevin Sep 13 '22 at 10:35
  • 1
    Also I would suggest you to use this life saver package: https://github.com/mcamara/laravel-localization – Kevin Sep 13 '22 at 10:35
  • @workservice I am unsure what you mean by " made the check", could you elucidate that ? – coderdonezo Sep 13 '22 at 11:14
  • 1
    @coderdonezo Are you sure that the edited file location is `resources/lang/de.json`? (I tested it in my local environment, and there is no problem) – Onur Uslu Sep 13 '22 at 17:11
  • 1
    @OnurUslu That was my problem, I had inadvertently created the json files in a subfolder of lang and had not realized. Thanks for pointing it out. – coderdonezo Sep 16 '22 at 10:41

0 Answers0