I'm having a problem with Laravel's blade templating syntax. When having something like:

<input placeholder="{{ __('My Tooltip') }}" />

that string won't be founded by POEdit. But on same file if I had this:

<span>{{ __('My Tooltip') }}</span>

that's OK.

I've already added a new extractor with follow configs but the problem persists.

Command: xgettext --language=Python --add-comments=TRANSLATORS: --force-po -o %o %C %K %F

An item in keywords list: -k%k

An item in input files list: %f

Source code charset: --from-code=%c

Anyone can help me?

1 Answers 11

You lie to Poedit about the content of these files, pretending they are Python, even when they are very clearly not. It’s not at all surprising that it doesn’t work to your liking. What would be surprising would be if it did. In this case, the reason seems to be clear: xgettext’s Python parser, naively trusting you and hopelessly confused as the result, sees the " in there as a start of a string literal not prefixed with __ and so skips over it.

Fix it by doing what the documentation says: use a dedicated tool to extract the string. In laravel-gettext's case that means using this command:

php artisan gettext:update

(Upcoming Poedit 2.0 will have direct support for template languages like this, but until then, you need to use the CLI tools.)

upvote
  flag
Thanks for your help! Meanwhile I copy about 20/30 entries and put in helper file and POEdit already extract that. I'll wait for Poedit 2.0. There's any release date already? – Miguel Oliveira
upvote
  flag
The extractor I describe above is a hack I found for blade's output syntax (curly braces) and I resolve pretty much of my problems! I understand the concept of these extractors (I had to create a couple of that - for jade templating, for javascript inside views, and other more) but I just want know if there would have an command option I could add to extract entries even inside quotes. Again, thanks for your suggestion but now people responsible to manage translations doesn't have tech skills to deal with artisan/shell console and also I had to change all my PO files location. – Miguel Oliveira
upvote
  flag
Translators are not expected to handle this. A reasonable developer follows what GNU gettext manual tells them to do, i.e. prepare POT files from sources (using console is a non-issue for developers, or should be). That is the only thing the translators need to work with, and that requires no shell, no knowledge, and no access to the source code. So much trouble saved by 10 mins of learning the proper gettext workflow... – Václav Slavík

Not the answer you're looking for? Browse other questions tagged or ask your own question.