0

Hi all i'm using Html package on laravel and i'm trying to use {{trans()}} into below code, but i could not do that and my result is php code

{!! Html::link('/password/email', "{{trans('strings.login_policies'))}}") !!}

or

{!! Html::link('/password/email', "trans('strings.login_policies')") !!}

My result:

<?php echo e(trans('strings.login_policies'))); ?> 

how to use trans into this code?

1 Answer 1

2

When the trans() function can not find the translation it will output the parameter string as is provided.

Are you sure the file strings.php exists in resources/lang/{defaultlocale}? And make sure there is a key login_policies in this file. All information on how to work with translations can be found in the laravel documentation.

Update

I didn't take a good look at your code, you don't need to use {{ and }} to use a string directly in a function call, this is only needed to output data directly into blade templates. You can just use the trans() function directly like so:

{!! Html::link('/password/email', trans('strings.login_policies')) !!}
Sign up to request clarification or add additional context in comments.

2 Comments

I haven't been using blade for a while, but doesn''t {!! escape the output for html? Should'nt it be just {{ Html::link('..?
It's the other way arround, {{ will escape html and {!! will allow it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.