I have languages for french and english. Fallback and standard is french (fr).
My folder structure:
This is the content of the login.php (english):
<?php
return [
'welcome' => 'Welcome',
'mail' => 'E-Mail address',
'password' => 'Password'
];
I am referencing the keys either using @lang()
or {{ trans('') }}
. Example:
<label for="email" class="col-md-4 control-label">{{ trans('admin.login.mail') }}</label>
However this gets returned as:
Localization feature of Laravel supports different language to be used in application. You need to store all the strings of different language in a file and these files are stored at resources/views directory. You should create a separate directory for each supported language.
Laravel-lang is a collection of over 68 language translations for Laravel by developer Fred Delrieu (caouecs), including authentication, pagination, passwords, and validation rules. This package also includes JSON files for many languages.
I use App::getLocale() which is probably the most supported way as the App::setLocale('EN') method is used in the documentation. You can use this method everywhere. If it throughs an error somewhere, you can use \App::... to make it work.
When you're putting language files into subfolder, you need to specify it using slash. So, try this instead:
{{ trans('admin/login.mail') }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With