如何为 Wordpress 创建 .mo 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4499622/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I create an .mo file for Wordpress
提问by Peter
I have some .po
files for Wordpress and i want to create .mo
files.
我有一些.po
Wordpress 文件,我想创建.mo
文件。
How can i do this?
我怎样才能做到这一点?
回答by Ionic? Biz?u
Linux
Linux
In Linux, you can just run this in Terminal:
在 Linux 中,您可以在终端中运行它:
msgcat yourFile.po | msgfmt -o generatedFile.mo -
or
或者
msgfmt -o generatedFile.mo yourFile.po
You can view more information about these commands by typing:
您可以通过键入以下内容来查看有关这些命令的更多信息:
man msgcat
man msgfmt
Mac OS X
Mac OS X
You can get msgcat
/msgfmt
(as above) either with Xcode or with brew install gettext
.
你可以得到msgcat
/ msgfmt
(如上),无论是在Xcode或brew install gettext
。
However, it will not add them to your path to avoid conflict with OS X's own gettext utility (says homebrew). You can either add it anyway by adding this to your bash_profile
:
但是,它不会将它们添加到您的路径中,以避免与 OS X 自己的 gettext 实用程序(如自制软件)发生冲突。您可以通过将其添加到您的bash_profile
:
export PATH=${PATH}:/usr/local/opt/gettext/bin
Or otherwise if you only need msgcat
/msgfmt
you can use aliases. Just add these lines to your bash_profile
:
否则,如果您只需要msgcat
/msgfmt
您可以使用别名。只需将这些行添加到您的bash_profile
:
msgcat='/usr/local/opt/gettext/bin/msgcat'
msgfmt='/usr/local/opt/gettext/bin/msgfmt'
Hope this helps! (Thanks to Georgi Stoyanov!)
希望这可以帮助!(感谢 Georgi Stoyanov!)
Windows
视窗
On windows you can install MinGW (Minimal GNU for Windows)you need to select mingw32-gettext (bin and dev) durring installation and msgfmt and msgcat exe files will be installed. By default in c:\MinGW\bin
. In order to use this tools you need to add that directory to your PATH variable. You can do that from command line using:
在 Windows 上你可以安装MinGW (Minimal GNU for Windows)你需要在安装过程中选择 mingw32-gettext (bin and dev) 并且 msgfmt 和 msgcat exe 文件将被安装。默认在c:\MinGW\bin
. 为了使用这个工具,你需要将该目录添加到你的 PATH 变量中。您可以使用以下命令从命令行执行此操作:
set PATH=%PATH%;c:\MinGW\bin
or from Control Panel > System and Security > System > Advanced System Settings > Environment Variables.
或从控制面板 > 系统和安全 > 系统 > 高级系统设置 > 环境变量。
回答by zubair
If you have opened POedit, then select language in which to translate and click on ok, then it fetch all the items/strings where __ or _e functions were applied to be translated. Just translate them and do these steps like go to catalog select update from sources and then save current catalog. MO file generated/updated successfully.
如果您已打开 POedit,则选择要翻译的语言并单击确定,然后它会获取应用 __ 或 _e 函数进行翻译的所有项目/字符串。只需翻译它们并执行这些步骤,例如从源中转到目录选择更新,然后保存当前目录。MO 文件已成功生成/更新。
Regards, Zubair Khan
问候,祖拜尔汗
回答by hangy
Generally, you could run the .po file through a tool like pocompile. Some editors are a bit more comfortable, for example, Poeditcan compile .mo files automatically. :)
通常,您可以通过pocompile 之类的工具运行 .po 文件。一些编辑器会更舒服一些,例如,Poedit可以自动编译 .mo 文件。:)
回答by markratledge
See http://codex.wordpress.org/WordPress_LocalizationWordPress in Your Language ? WordPress Codex and http://codex.wordpress.org/Files_For_Direct_TranslationFiles For Direct Translation ? WordPress Codex and http://codex.wordpress.org/I18n_for_WordPress_DevelopersI18n for WordPress Developers ? WordPress Codex
请参阅http://codex.wordpress.org/WordPress_Localization用您的语言编写WordPress 吗?用于直接翻译的WordPress Codex 和 http://codex.wordpress.org/Files_For_Direct_Translation文件?WordPress Codex 和 http://codex.wordpress.org/I18n_for_WordPress_DevelopersWordPress 开发人员的 I18n ?WordPress 手抄本