Stichoza / google-translate-php

🔤 Free Google Translate API PHP Package. Translates totally free of charge.
MIT License
1.82k stars 383 forks source link

How can I use it in Blade #128

Closed dreigningking closed 4 years ago

dreigningking commented 4 years ago

Please tell me how to use this in blade views?

Stichoza commented 4 years ago

This is not a Laravel package, it's framework agnostic.

But you can create your own facades or Blade directives if you want, something like @translate() and it could use the methods of this package.

iamB0rgy commented 1 year ago

So, this won't work?

{{ GoogleTranslate::trans('{{ $items->name }}', app()->getLocale()) }}

Stichoza commented 1 year ago

@iamB0rgy You shouldn't pass parameter in blade curly braces, do this instead:

{{ GoogleTranslate::trans($items->name, app()->getLocale()) }}
iamB0rgy commented 1 year ago

Thank you. It worked!