php – Is there an easy way to implement a Translator-like string picker?-ThrowExceptions

Exception or error:

I was wondering if there was an easy way to implement something like the __ function, but not related to locale.

Imagine something like the_function('messages.welcome', 'test') which retrieves the corresponding welcome string from an array in some test/messages.php file based on the passed value. Just like localization, only not depending on the locale but rather anything else (in this case the string test).

Of course I could build this from the ground up, I was just wondering if there was some Laravel internal I could re-use for the purpose, or if there is some package already doing this job, or if there’s some other method of doing this I didn’t think of.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *