Aljosha Papsch <aljosha.pap...@vinexus.eu> writes: > The remaining pieces are messages from a MySQL database and for that I > would like to know your opinion about the best approach. On the web is > an example[1] which writes translatable messages directly to a .po > file.
Actually, the example does not seem to produce a .po file, but a .pot file, which can be used as an input of xgettext. That sounds a reasonable solution, since neither YAML nor JSON has a standard mechanism to mark strings translatable. > That's certainly doable for me, though surely it's better to let > xgettext be the sole creator of .po files instead of a home brew > solution? Instead, I could imagine writing to a JSON file that simply > lists the messages like this: > > [ > "Greece", > "Nice and sunny", > "Spain", > "Just as nice and sunny" > ] > > This file can be consumed by xgettext because JSON is a subset of > JavaScript. If you simply extract all strings in a JSON file, it is possible with xgettext -L JavaScript -a. However, if you want to extract certain strings from a JSON file, I'd suggest to use an intermediate .pot file as above, using something like JSONPath. Regards, -- Daiki Ueno