lundi 24 décembre 2018

Get localized string on the fly

I am trying to run a seeder for getting a string in different locale (I stored the lang file in lang/es.json).

(For being able to search in both english and spanish, I needed to store both values in database). Now, I'm trying to run it inside my seeder:

 App::setLocale('es');
 dd(__('Hello Wolrd'));

but this doesn't work.

I'd want to say something like:

App::getLocalizedString('Hello World', 'es');

Also, I'll want to use it inside my Observer too, so I don't want to change user's locale. I just want to get a string based on given locale.

Is there a way to achieve that?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire