POEdit不会在HTML标签中提取字符串 [英] POEdit doesn't extract string in HTML tags

查看:219
本文介绍了POEdit不会在HTML标签中提取字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Laravel的刀片模板语法有疑问. 当有类似的东西时:

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

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

该字符串不会由POEdit建立.但是如果有,在同一文件上:

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

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

没关系.

我已经添加了带有跟随配置的新提取器,但是问题仍然存在.

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

命令: xgettext --language = Python --add-comments =翻译:--force-po -o%o%C%K%F

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

关键字列表中的一项: -k%k

输入文件列表中的一项:%f

源代码字符集: --from-code =%c

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

有人可以帮助我吗?

推荐答案

撒谎对这些文件的内容进行Poedit,假装它们是Python,即使它们显然不是.这并不符合您的喜好也就不足为奇了.如果 did 是令人惊讶的.在这种情况下,原因似乎很清楚:xgettext的Python解析器天真地信任您,并且毫无希望地感到困惑,结果看到其中的"为不带__前缀的字符串文字的开头,因此跳过它.

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.

通过执行文档所说的内容来解决:使用专用工具提取字符串.在laravel-gettext的情况下,这意味着使用以下命令:

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

(即将推出的Poedit 2.0将直接支持这种模板语言,但在此之前,您需要使用CLI工具.)

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

这篇关于POEdit不会在HTML标签中提取字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆