Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Laravel Translation With Variables Example
Code And Deploy
Code And Deploy

Posted on

     

Laravel Translation With Variables Example

Originally posted @https://codeanddeploy.com visit and download the sample code:
https://codeanddeploy.com/blog/laravel/laravel-translation-with-variables-example

In this post, I will show you how to implementLaravel translation with variables. Building a Laravel Application with multi-language is amazing and it is easy to do it with the Laravel framework. How about you want to pass a dynamic value to your language with a variable/placeholder?

So let's say this is your English language.

{"This is a sample message for :name with another :variable2":"This is a sample message for :name with another :variable2"}
Enter fullscreen modeExit fullscreen mode

So, how to input a dynamic value to your language variable/placeholder?

See the example below:

$name="your dynamic value here";$variable2="dynamic value for variable 2";// you can do it inside your PHP code like controllertrans('This is a sample message for :name with another :variable2',['name'=>$name,'variable2'=>$variable2]);// or this helper function__('This is a sample message for :name with another :variable2',['name'=>$name,'variable2'=>$variable2]);// for blade template@lang('This is a sample message for :name with another :variable2',['name'=>$name,'variable2'=>$variable2]);
Enter fullscreen modeExit fullscreen mode

I hope this tutorial can help you. Kindly visit herehttps://codeanddeploy.com/blog/laravel/laravel-translation-with-variables-example if you want to download this code.

Happy coding :)

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

We code, You Deploy.
  • Joined

More fromCode And Deploy

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp