-1

I have An Array Like This In Laravel Blade:

$myArray={names:{"name1","name2","name3","name4","name5"}}


I call theme in my blade file like this :

@foreach($myArray as $ma)
{{$ma->names}}<br>
@endforeach

result ::

name1
name2
name3
name4
name5

I want to translate my names array to another language(spanish) and show them on view file, how can i do this?
::MY Result That I Want To Be Like This::

nombre1
nombre2
nombre3
nombre4
nombre5
Amin Arjmand
  • 435
  • 7
  • 21

1 Answers1

1

Docs:

https://laravel.com/docs/5.7/localization

Create a translation file for the language you need, i.e.:

<?php

// resources/lang/en/messages.php

return [
    'welcome' => 'Welcome'
];

Then you can use @lang('messages.welcome') in blade templates to get the translation.

Flame
  • 6,663
  • 3
  • 33
  • 53