Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

poedit workaround for dynamic gettext

I have started using gettext for translating text and messages i send to user. I am using poedit as an editor, but i am struggling with dynamic messages.

For example i have things like the login where i have a variable that tells the type of error.

$this->translate('page-error-' . $error);

When i auto update from poedit this gets read like "page-error-". What i do is have a file where i place dummy calls to the translate method with all the possible keys to have them added in my poedit when auto updating.

I don't particularly like this situation. How do you guys do it.

Thanks for your ideas

like image 555
Gabriel Solomon Avatar asked May 16 '09 18:05

Gabriel Solomon


2 Answers

No -- this is not possible, because the editor (and the gettext tools) are reading your sources, not executing your program. You'll have to keep the dummy calls or add the keys to the translation files yourself.

like image 144
millenomi Avatar answered Sep 28 '22 07:09

millenomi


Are you trying something like

$this->translate(sprintf('page-error-%s', $error));
like image 30
raspi Avatar answered Sep 28 '22 06:09

raspi