【问题标题】:Xgettext is not working on Debian 10 with apache2 and gettext installedXgettext 不适用于安装了 apache2 和 gettext 的 Debian 10
【发布时间】:2021-08-06 11:43:09
【问题描述】:

假设:已安装 debian10 + apache2 + gettext 包。有一个带有一些 php+html 代码的 .php 文件。我尝试使用 xgettext 从这个 .php 文件中获取要翻译的字符串并将它们保存到 .pot 文件中。来自指令(https://www.systutorials.com/docs/linux/man/1-xgettext/):

xgettext testfile.php -o locale/pot/testfile.pot

“locale”文件夹和“testfile.php”文件在同一个目录下。 “locale/pot”文件夹也是 777 可写的,“testfile.php”也是 777。当我从 shell(从 root)运行上面提到的命令时,没有生成 testfile.pot。我还尝试添加 --debug 选项,但在 shell 中没有信息/没有错误。可能是什么原因?

UPD:我也试过了:

xgettext testfile.php -o locale/pot/testfile.pot --debug --force-po

使用 --force-po 它会创建一个文件“testfile.pot”,但没有用于翻译的字符串 - 只有带有内容的模板:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-06 14:51+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

所以还是没有运气......

【问题讨论】:

  • 当我在 shell 中运行 xgettext -V 和 gettext -V 命令时,我看到这些工具已经安装并且版本是 0.19.8.1

标签: xgettext


【解决方案1】:

是的,现在我猜到了这个谜语。 Xgettext 仅从gettext("some text string") 获取字符串,而不从echo 或print_r 获取文本。哈哈!所以最后我必须通过改变 echo->gettext 来重写我的代码,或者找到另一个工具来抓取字符串。谢谢=)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-14
    • 1970-01-01
    • 1970-01-01
    • 2021-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多