php 如何在 WooCommerce 2.2+ 上手动安装翻译文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26022405/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 18:06:47  来源:igfitidea点击:

How to manually install translations files on WooCommerce 2.2+?

phpwordpresswoocommerce

提问by knarf

I want the WooCommerce plugin to display french text (fr_FR). The rest of Wordpress is correctly set to french but WooCommerce still shows english.

我希望 WooCommerce 插件显示法语文本 ( fr_FR)。Wordpress 的其余部分已正确设置为法语,但 WooCommerce 仍显示英语。

Since version 2.2 language packs are not included. This message is displayed on the admin page:

由于不包括 2.2 版语言包。此消息显示在管理页面上:

woocommerce translation available

woocommerce 翻译可用

The recommended automatic "Update translation" procedure involves giving FTP access to my server which I would like to avoid.

推荐的自动“更新转换”程序涉及让 FTP 访问我的服务器,我想避免这种情况。

There are fr_FRtranslations available in the WooCommerce git repo:

fr_FRWooCommerce git repo 中有可用的翻译:

https://github.com/woothemes/woocommerce-language-packs/raw/master/packages/fr_FR.zip

https://github.com/woothemes/woocommerce-language-packs/raw/master/packages/fr_FR.zip

I've unziped that in the same folder as the default english language files.

我已将其解压缩到与默认英语语言文件相同的文件夹中。

$ ls -l wp-content/plugins/woocommerce/i18n/languages 
total 1320
-rw-r--r-- 1 knarf users 211452 24 sept. 18:01 fr_FR.zip
-rw-r--r-- 1 knarf users 116765 22 sept. 10:48 woocommerce-admin-fr_FR.mo
-rw-r--r-- 1 knarf users 211901 22 sept. 10:48 woocommerce-admin-fr_FR.po
-rw-r--r-- 1 knarf users 162575 18 sept. 14:48 woocommerce-admin.pot
-rw-r--r-- 1 knarf users 163575 22 sept. 10:48 woocommerce-fr_FR.mo
-rw-r--r-- 1 knarf users 268719 22 sept. 10:48 woocommerce-fr_FR.po
-rw-r--r-- 1 knarf users 208795 18 sept. 14:48 woocommerce.pot

I've tried setting WPLANGto french in wp-config.php:

我试过设置WPLANG为法语wp-config.php

define ('WPLANG', 'fr_FR');

Despite all this, The "WooCommerce Translation Available" message is still there and WooCommerce interface is still in english. How do I force WooCommerce to switch to french?

尽管如此,“WooCommerce 翻译可用”消息仍然存在,WooCommerce 界面仍然是英文的。如何强制 WooCommerce 切换到法语?

Running the "Force Update Translation" procedure (from the message) fails with:

运行“强制更新转换”过程(来自消息)失败,并显示:

Failed to install/update the translation: An authentication error occurred while updating the translation. Please try again or configure your Upgrade Constants.

无法安装/更新翻译:更新翻译时发生身份验证错误。请重试或配置您的升级常量。

I'm using a fresh install of WordPress 4.0 (french release) and WooCommerce 2.2.4.

我正在使用全新安装的 WordPress 4.0(法语版)和 WooCommerce 2.2.4。

回答by helgatheviking

From the Translation Docs

来自翻译文档

PO and MO files will be downloaded in wp-content/languages/woocommerce.

PO 和 MO 文件将在 wp-content/languages/woocommerce 中下载。

So the woocommerce plugin folder is the wrong place to upload the language pack.

所以woocommerce插件文件夹是上传语言包的错误位置。

Edit: Important note concerning Language codes

编辑:关于语言代码的重要说明

Per @Julian Moreno's comment, the language code (and subsequent code) for WooCommerce must match the code you are using for WordPress.

根据@Julian Moreno 的评论,WooCommerce 的语言代码(和后续代码)必须与您用于 WordPress 的代码相匹配。

In my case WordPress is "es_MX" and WooCommerce must be also "es_MX".

就我而言,WordPress 是“es_MX”,而 WooCommerce 也必须是“es_MX”。

回答by Bhaskar Bhatt

I had the same issuewhen I have changed WooCommerce basic language from English To Danish. Til after that it was showing English rather than Danish for WooCommerce Pages.

当我将 WooCommerce 基本语言从英语更改为丹麦语时,我遇到了同样的问题。在那之后,WooCommerce Pages 显示的是英语而不是丹麦语。

Then I noticed from this tutorial WooCommerce Translate Language

然后我从本教程中注意到WooCommerce 翻译语言

I had to place WooCommerce plugin translation files at

我不得不将WooCommerce 插件翻译文件放在

'wp-content/languages/plugin/woocommerce'

'wp-content/languages/plugin/woocommerce'