xitrum-framework / scala-xgettext

Scala compiler plugin that acts like GNU xgettext command to extract i18n strings in Scala source code files to Gettext .po file
http://www.slideshare.net/ngocdaothanh/i18nize-scala-program-a-la-gettext
MIT License
25 stars 11 forks source link

Add format tag to .pot: #, java-format #22

Open Ahnfelt opened 5 years ago

Ahnfelt commented 5 years ago

The current implementation doesn't seem to add the #, java-format flag as documented here:

https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html#The-Format-of-PO-Files

Tools like Poedit understand this flag and displays it to translators:

billede

Translation tools may also use this to validate that all placeholders are used in the translation, and that they are syntactically well formed.

ngocdaothanh commented 5 years ago

scala-xgettext doesn't enforce a specific text format. It only extracts texts. Users can freely choose format they want.

Ahnfelt commented 5 years ago

Hmm, if you don't add format tags - then how do you make tools like Poedit report errors like the following?

Screen Shot 2019-05-27 at 11 19 08

Note that I'm using #, c-format - the #, java-format was the wrong tag to use for printf-style format strings.

ngocdaothanh commented 5 years ago

Do you have a proposal how to automatically add that info?

Ahnfelt commented 5 years ago

Perhaps an optional tag parameter at the end of the method name configuration?

scalacOptions += "-P:xgettext:t:tf:c-format"

This would cause all strings extracted from calls to the tf method to get the #, c-format tag.

ngocdaothanh commented 5 years ago

I guess that's the best we can do. Please create a pull request.

Note that there are several existing options, as listed in README: https://github.com/xitrum-framework/scala-xgettext/blob/master/README.rst