Closed alariva closed 8 years ago
Hi!
I often use dynamic translations too and unfortunately, the only way I have found to handle this case is to put a trans with all possible dynamic values in comments before the line where I use them.
/*
trans('message.field.one')
trans('message.field.two')
*/
echo trans('message.field.' . $var );
There is no other workaround with my plugin at this time...
Seems like a good workaround, though. Thank you!
I just have read my code and fortunately there is something about obsolete lemma !
You need to define a configuration parameter named never_obsolete_keys
. It is an array of words. All lemma (the id you put in the trans function) containing one of these words will never be considered as obsolete.
Unfortunately the plugin cannot guess what will be the different values of your dynamic php variable... So the plugin cannot create the translations in the Lang files.
Yeah, I've seen that, but I was willing to actually have this separation or real obsolete (as to clean them up) and the dynamic fields. Maybe I can get this done by two runs with different parameters, but would take some manual task and human-error risk.
I'm using the following technique to load dynamic translations like so:
trans('appointments.status.'.$appointment->statusLabel)
I've seen I can avoid them getting into Obsolete by naming the key like
trans('appointments.status.dynamic.'.$appointment->statusLabel)
for which I'd use a translation like so:But after running
php artisan localization:missing
the set does not appear at all, either in Obsolete or Translated sections.Am I missing anything about how to use the command? Have you got any suggestions?
Thank you in advance!
You can find the project here to see other cases where I'm using this approach.