laravellaravel-9laravel-localization

I don't know how to change that with Laravel Localization, in my preferred language, it seems complicated


I don't know how to change that with Laravel Localization, in my preferred language, it seems complicated.

I'm a student and in my project I have to send an email that's in my own language 'Persian', but I don't know how to use Localization here.

@lang( "If you're having trouble clicking the \":actionText\" button, copy and paste the URL below\n". 'into your web browser:', [ 'actionText' => $actionText, ] )

I don't know what to do in my .json language file. Thanks for the help.


Solution

  • The simple way is to create different language files in the lang directory. In your case, you can generate en.php for English and fa.php for Persian. In these two files, set the same variable with different language values. And then, use that variable in your resource blade file.

    Example,

    in Lang/en/main.php

    <?php
    return[
       'hello' => 'Hello',
    ];
    

    in Lang/fa/main.php

    <?php
    return[
       'hello' => 'سلام',
    ];
    

    in main.blade.php

     {{__('main.hello')}}