samedi 8 décembre 2018

Translate string to fallback locale programatically

I have a .json translation file and it all works.

I have a search functionality where I store the values in my database in english (which is my fallback language), however when the user is seeing the translated page, he'll type it in his language.

Is there a way to translate a string on the fly programatically? Maybe something like this:

$engStr = __("Hola")->toFallback();

// or

$engStr = __("Hola", 'en');

Because app()->getLocale() knows the current locale.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire