0

I started to prepare localization strings for my application based on Laravel 8.19, and I found that nested arrays are not working. I copied auth.php from \resources\lang\en to \resources\lang\ru and added few strings in nested array

    'login' => 'Войти',
    'logout' => 'Выйти',
    'password' => [
        'definition' => 'пароль',
        'forgot' => 'Забыли пароль?',
    ],
    'remember' => 'Запомнить меня',
    'failed' => 'Учетные данные не совпадают с нашими записями.',
    'password' => 'Пароль неверный.',
    'throttle' => 'Слишком много попыток входа. Пожалуйста попробуйте снова через :seconds секунд.',

Then in login page \resources\views\auth\login.blade.php I try to echo lang strings.

<div class="flex items-center justify-end mt-4">
    @if (Route::has('password.request'))
    <a class="underline text-sm text-gray-600 hover:text-gray-900" 
       href="{{ route('password.request') }}">
        {{ __('auth.password.forgot') }}
    </a>
   @endif
   <x-button class="ml-3">
        {{ __('auth.login') }}
   </x-button>
</div>

But auth.password.definition and auth.password.forgot are not working. I see "auth.password.definition" on the page like I don't have this string defined in the auth.php file. What can be wrong?

I found in my old project on Laravel 5 that I used the trans() function to retrieve localization strings, and it also worked with nested arrays like above. Now trans() cannot help with that.

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
schel4ok
  • 634
  • 1
  • 11
  • 33

1 Answers1

0

It seems that nested arrays notation for localization strings replaced with simple DOT delimiter in KEY name, because I tried like that and it works.

    'password.forgot'   => 'Забыли пароль?',
schel4ok
  • 634
  • 1
  • 11
  • 33