POEdit doesn't extract string in HTML tags

◇◆丶佛笑我妖孽 提交于 2019-11-29 20:06:53

问题


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:


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



来源:https://stackoverflow.com/questions/34243278/poedit-doesnt-extract-string-in-html-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!