回答
明白了:
find . -iname "*.php" | xargs xgettext
我试图用-exec
之前,但只运行一次一个文件。这使他们在一堆。
Yay Google!
这是Windows的解决方案。首先,安装gettext并从GnuWin32工具集合中找到。
- http://gnuwin32.sourceforge.net/packages/gettext.htm
- gnuwin32.sourceforge.net/packages/findutils.htm
您可以运行以下命令算账:
find /source/directory -iname "*.php" -exec xgettext -j -o /output/directory/messages.pot {} ;
的输出文件之前存在运行命令,所以新的定义可以与它合并。
也许安装和使用Cygwin?我知道这不是本机解决方案,但应该得到相同的结果。 – neezer 2009-12-10 18:03:57
对于Windows命令行simpe的解决方案是:
@echo off
echo Generating file list..
dir html\wp-content\themes\wpt\*.php /L /B /S > %TEMP%\listfile.txt
echo Generating .POT file...
xgettext -k_e -k__ --from-code utf-8 -o html\wp-content\themes\wpt\lang\wpt.pot -L PHP --no-wrap -D html\wp-content\themes\wpt -f %TEMP%\listfile.txt
echo Done.
del %TEMP%\listfile.txt
一些警告以防万一:'pygettext.py'不支持'-f'选项。 – Morwenn 2013-03-28 13:07:36
这是我发现的递归搜索Mac系统的解决方案:
xgettext -o translations/messages.pot --keyword=gettext `find . -name "*.php"`
生成的文件,其对方法的gettext的所有用途项扩展名是php,包括子文件夹并将它们插入到translations/messages.pot中。
留下一些描述性文字 – 2015-11-05 20:46:42
你不能用一个单一的命令来实现这一点。 xgettext选项--files-from
是你的朋友。
find . -name '*.php' >POTFILES
xgettext --files-from=POTFILES
如果你是积极的,你没有,你也可以使用find
太多的源文件与xargs
:
find . -name "*.php" -print0 | xargs -0 xgettext
但是,如果你有太多的源文件,xargs
将调用xgettext
多次,以便不超过平台的最大命令行长度。为了保护自己免受这种情况下,你必须使用了xgettext选项-j
,--join-existing
,删除过时的消息第一个文件,并开始与一个空,这样了xgettext没有摆脱困境:
rm -f messages.po
echo >messages.po
find . -name "*.php" -print0 | xargs -0 xgettext --join-existing
相比之下,与首先给出POTFILES
中的源文件列表的简单解决方案!
使用find
与--exec
效率非常低,因为它会调用xgettext -j
一次为每个源文件搜索可翻译的字符串。在xgettext -j
的特殊情况下,它更加低效,因为xgettext必须随每次调用(即每个输入源文件)读取不断增长的现有输出文件messages.po
。
- 1. xgettext in gtk +
- 2. Haskell Recusive Types int2nat
- 3. Recusive SQL查询
- 4. SQL Server Recusive Query
- 5. Recusive功能
- 6. python行号与xgettext
- 7. 从csv文件xgettext
- 8. Log Parser recusive file read
- 9. 的java了xgettext提取键
- 10. Webpack TypeScript和xgettext翻译
- 11. 我没有从xgettext输出
- 12. Javascript承诺recusive功能
- 13. XSLT/XSL Recusive嵌套元素
- 14. Recusive延迟加载问题
- 15. 获取recusive observablecollection的项目
- 16. 与FactoryGirl的Recusive协会
- 17. 如何让xgettext支持i18n Java?
- 18. xgettext和msgmerge的字符集问题
- 19. xgettext不会扫描复数形式
- 20. 本地化使用Django和了xgettext
- 21. xgettext从html文件生成po文件
- 22. VBscript Recusive函数问题返回值
- 23. Recusive排序正则表达式
- 24. 使用xslt,xpath:document()和mediawiki的Recusive转换
- 25. Haskell中的Recusive列表函数
- 26. 关于recusive函数的困惑
- 27. 来自Catch块的Recusive调用
- 28. Windows错误:错误发生,而在__init__.py了xgettext运行“了xgettext”不是recognizad内部或外部命令
- 29. 只能使用xgettext来提取特定的域字符串吗?
- 30. I18n for XSLT(或者什么是XSLT的C++的gettext()和xgettext)?
好吧,它不适合我,但你告诉我一种可能性的方式,否则将被接受,并与它一起生活,好像没有更好的方式,这 – 2013-07-28 07:32:45
嗨,尼斯工作,但becarefull添加-j在该命令,除非它不会工作 – Ata 2014-04-18 16:50:02
这是错误的,因为如果文件太多以适合一个命令行,xargs会多次运行xgettext,导致较早的调用被破坏。只需要添加-j也是不对的,因为你需要先删除文件,否则你会加入旧数据。 – 2014-05-01 20:37:50