Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

POEdit doesn't extract string in HTML tags

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?

like image 391
Miguel Oliveira Avatar asked Dec 12 '15 18:12

Miguel Oliveira


1 Answers

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.)

like image 52
Václav Slavík Avatar answered Dec 24 '22 12:12

Václav Slavík