2

Context : I currently have an hybrid application. I've been using poedit as a tool to generate keys within my .po files and thus far, everything works fine.

Altough I've encountered a weird situation and i can't find anything relevant on the web. You are my best hope stackoverflow-kenobi.

Explanation : I'm currently refactoring some code, and assessed that we have many error message that have been duplicated throughout the application.

I've created some constants to be used like that

public const ERROR_UNKNOWN = 'An stupid error happenned, but we don't know why';

I've then worked in my controller to display the correct error message.

//some code
$this->translator->translate(self::ERROR_UNKNOWN);
//more code

Problem : When doing this, the keys are not in the .po files anymore.

Has anyone encountered this situation ? Have you find any solution to make things work ? I haven't seen anyone talking about this on the web. Hope someone here found something.

Have a nice day, and thank you for reading

Cid
  • 14,968
  • 4
  • 30
  • 45
Unex
  • 1,747
  • 13
  • 17

1 Answers1

0

So I think what you want is xgettext to parse variables?

Spoiler: not that easy (afaik)

The best I can think of is to trick it into parsing your keys, in this fashion: Translate variables with POEdit/xgettext

You could list all possible errors in a dedicated dictionary (which would be xgettext "parsable") and only store the keys in constants

Pierre vDEV
  • 164
  • 1
  • 11