How to get translate message in controller Laravel?

OPV

I have file excel.php by the path /resources/lang/en/excel.php

Then in controller I tried to fetch word by key:

use Lang;

echo Lang::get('excel.idEvent');

Also I tried:

dd(echo __('excel.idEvent'));

Whats is right way to do that?

nakov

If you use JSON translation files, you might have to use __().

Here are all the ways to use:

@lang('...')  // only in blade files
__('...')
Lang::get('...')
trans('...')
app('translator')->get('...')
Lang::trans('...')

They all defer to \Illuminate\Translation\Translator::get() eventually.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Laravel 5.7: How can I translate the text of reset password message

how to translate the result not found message of a select2 with laravel

How to translate routes in Laravel?

how to translate throttle in laravel?

How to translate the disable_with message

Magento - how to translate message type

How to display a success message upon redirection from controller in Laravel?

Laravel 5.2: how to get Model properties in a Controller

How to use get object in controller laravel

How to get a Model in function of controller in Laravel 5.2?

How to get logged in user in a laravel controller constructor

How to get logged in user data into Laravel controller

how to get url parameter in controller in laravel?

How to get ID User from Laravel Controller

how to get json object in laravel controller

How to Get Data from Laravel Controller and Compare It?

How to get the error message in Controller or Route after handled exception in errorHandler?

How to get the error message in Controller or Route after handling exception in errorHandler?

How to translate collections in Laravel 5?

Vuejs and Laravel: How to use http get to pass an array to Laravel controller

How to un-translate a message translated with gettext?

laravel translate number to month or how to make created_at get the value of month name?

How to get all values from Laravel controller to index using JavaScript?

How to get all possible error messages of a Laravel Controller method

Laravel, How to get array of session in controller and compare with model

Laravel 5.2 - How to get id of newly created user and pass it to a controller

How to get the column values according to id inside blade and controller in Laravel?

Laravel how to get auth user details in apiResources controller

How can I get the lang inside my controller in laravel