Php – 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

Best Solution

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.

Related Question