#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Using the trans() and Lang::get() Methods

Laravel provides two main ways to retrieve a translated string: the trans() helper function and the Lang facade — both read from the same underlying language files.

Using trans()

echo trans('messages.welcome');

In Blade views, the shorthand @lang directive or the __() helper are commonly used instead:

{{ __('messages.welcome') }}

Using Lang::get()

echo Lang::get('messages.welcome');

Lang::get() and trans() are functionally equivalent — trans() is simply a convenient global wrapper around the Lang facade.

Passing Placeholders

// lang/en/messages.php
'greeting' => 'Hello, :name!',
echo trans('messages.greeting', ['name' => 'Ravi']);

Handling Pluralization

'apples' => '{0} No apples|{1} One apple|[2,*] :count apples',
echo trans_choice('messages.apples', $count);

Retrieving strings is only half the picture — keeping the underlying language files organized as an app grows in size and language count is just as important.

Ready to master Laravel Training Course?

Join Uncodemy's hands-on Laravel program and build real, production-ready applications.

Explore Course