wordpress .po 文件中的 #: (文件, 行号) 行是否必要

发布于 2024-11-09 10:41:04 字数 395 浏览 0 评论 0原文

WordPress 翻译需要一个 [主题名称].po 文件,其中包含翻译的键值映射,例如:

#: ../single-con_book_reviews.php:197
msgid "Author: "
msgstr ""

但是,将每次出现“作者”一词的文件和行号:“既艰巨又愚蠢。是必须的吗?或者我可以使用理智:

msgid "Author: "
msgstr ""

或者,我只是在这里遗漏了一些东西吗?

看看,放置文件的问题&行号是它会阻止您编写任何新代码或删除任何旧代码。如果您在 1200 行 php 文件的开头添加一行,您就会突然破坏所有翻译映射。当然这些只是评论......对吧?

Wordpress translation calls for a [theme name].po file, in which are your key value mapping for your translations, such as:

#: ../single-con_book_reviews.php:197
msgid "Author: "
msgstr ""

However, putting the file and line number of every occurrence of the word "Author: " is arduous and silly. Is it required? Or can I just use the saner:

msgid "Author: "
msgstr ""

OR, am I just missing something here?

See, the problem with putting the file & line number is it would discourage you from ever writing any new or removing any old code. If you add a line at the beginning of a 1200 line php file you've suddenly ruined all of your translation mappings. Surely these are more of just comments... right?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

思念满溢 2024-11-16 10:41:04

这是一条评论,不是必需的。它的存在主要是出于历史原因,更难以找出特定字符串出现的位置。另外,这通常(当时和现在)由解析器自动添加,解析器直接从源创建翻译模板,而不是手动创建。

Its a comment and its not required. Its there mostly for historical reason, where it were more difficult to find out, where a specific string occurs. Additional this is usually (then and now) added automatically by a parser, that creates the translate-templates right from the source, and not manually by hand.

反话 2024-11-16 10:41:04

.po 文件中,所有以 # 开头的行都是可选的。尽管如此,这并不意味着它们是不必要的或无用的。

例如,带有 #: 的行确实指定了源代码中字符串的位置,这在您尝试解决国际化问题时非常有用。

另外,我不建议您为 .po 文件编写自己的解析器,因为即使这种格式可能看起来很容易阅读,但解析起来却并不那么简单 - 它有很多不具备的功能。明显的。您最终会浪费时间来改进部分解析器。相反,请选择现有的。

All lines starting with # are optionals in .po files. Still, this does not mean that they are unnecessary or useless.

For example the lines with #: do specify location of the strings in source code, something very useful when you try to solve internationalization issues.

Also, I would not recommend you to write your own parser for .po files because even it this format may seam simple to read, it is not so simple to parse - it has lots of features that are not obvious. You will end up wasting time on improving your partial parser. Instead go for an existing one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文