How to translate Laravel?

Asked

Viewed 4,047 times

2

inserir a descrição da imagem aquiclone that repository https://github.com/caouecs/Laravel-lang.git with language pack for Laravel, copied the en-BR folder to Resources/lang, changed the locale and fallback_locale to en-BR, but my page has not been translated, only the validation messages!

Alterações para tradução do Idioma

  • 4

    Because that translation you provoked in your only server code for validation, pagination, passwords and auth ... the rest is not really translated.

3 answers

2

I created an account just to answer correctly (since more than 2000 people have seen this question). Actually, the problem there was very simple: the package comes with the folder "pt_BR" (with underline and capital BR). The json file in the "Resources/lang" folder must be named exactly as it is in the "config/app.php" file. In your case (and in mine) "en". With dash and all minuscule. If you find some other untranslated line, just add to the json file by following the same formatting.

1


This standard package translates only validations and messages generated by the Standard.

The messages of Blade are not translated by default, you also have to prepare your Blade to be translated.

look here in the documentation that will clarify you better https://laravel.com/docs/5.6/localization

1

I solved it this way:

  • I changed the settings in the app.php file as below: 'Timezone' => 'America/Sao_paulo', 'locale' => 'en-BR', 'fallback_locale' => 'en',

  • I created a copy of the en folder (which is inside lang) and renamed it to en-BR

  • I cleaned the configuration file with the command: php Artisan config:clear

From there the translations in the field validations worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.