views:

318

answers:

2

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

+1  A: 

Are you trying something like

$this->translate(sprintf('page-error-%s', $error));
raspi
how i make the dinamic keys is not the problem, the problem is how you add them in poedit.
solomongaby
+1  A: 

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.

millenomi
how can i add keys manually ? i wasnt able to find a way. Also are those manuallly keys removed when doing a sync with sources ?
solomongaby