php 在 WordPress 中将 HTML 语言从 en-US 更改为 en-GB?

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

Change HTML language from en-US in to en-GB in WordPress?

phphtmlwordpresswordpress-theming

提问by Martin Bean

This may sound like a simple and trivial question, but I'm using the following tag in a WordPress theme header file:

这听起来像是一个简单而微不足道的问题,但我在 WordPress 主题头文件中使用了以下标签:

<html <?php language_attributes(); ?>>

Which is outputting:

这是输出:

<html dir="ltr" lang="en-US">

I wish to change the langattribute to "en-GB" as my blog and the language posts are written in are British English (en-GB) but I can't find where this parameter is set in the WordPress admin settings, and there isn't a value for it in the wp_optionsdatabase table either, which leaves me to believe setting the langvalue must be some sort of dark art?

我希望将lang属性更改为“en-GB”,因为我的博客和语言帖子是用英式英语 (en-GB) 编写的,但是我在 WordPress 管理设置中找不到此参数的设置位置,并且没有在wp_options数据库表中也不是它的值,这让我相信设置lang值必须是某种黑暗艺术?

回答by itsreeyan

Define the language attribute using:

使用以下命令定义语言属性:

define ('WPLANG', 'en-GB');

You can get more information on it at http://codex.wordpress.org/Installing_WordPress_in_Your_Language

您可以在http://codex.wordpress.org/Installing_WordPress_in_Your_Language获得更多信息

回答by Abu Roma?ssae

As for recent version of WordPress 4+ this option

至于最近版本的 WordPress 4+ 这个选项

define ('WPLANG', 'en-GB');

is deprecated, to update the language you need to follow either one of the following methods:

已弃用,要更新您需要遵循以下任一方法的语言:

Method 1

方法一

Inside the wp-config.phpput the following line:

wp-config.php 中放置以下行:

$locale='en_GB';

Method 2 (recommended)

方法二(推荐)

In database, XY_optionstable to and set an option of WPLANto en_GB(where XY is the table prefix for your wordpress installation)

在数据库中,将XY_options表设置为WPLAN选项并将其设置为en_GB(其中 XY 是 wordpress 安装的表前缀)

exemple queries:

示例查询:

insert

插入

INSERT INTO `XY_options` (`option_id`, `option_name`, `option_value`, `autoload`) VALUES (NULL, 'WPLANG', 'en_GB', 'yes');

update

更新

UPDATE `XY_options` SET `option_value` = 'en_GB' WHERE `option_name` = 'WPLANG';

回答by Do Nhu Vy

I am using Wordpress 5.1.1 , at wp-config.php, choose right top line, put

我正在使用 Wordpress 5.1.1 ,在wp-config.php,选择右顶行,放

$locale='vi_VN';

(For example, in case of Vietnamese language)

(例如,如果是越南语)

回答by Adriano Lucas

A bit late in the discussion here. I had the same need today and found that there is a plugin available for that: CHL-Change HTML Lang. The language of the backend/admin interface can be in one language while the posts/articles/portfolios can be set in another language. After activating the plugin hit Settings→General and change the HTML language tag, i.e., en-US, etc.

这里的讨论有点晚了。我今天也有同样的需求,发现有一个插件可用:CHL-Change HTML Lang。后端/管理界面的语言可以是一种语言,而帖子/文章/作品集可以设置为另一种语言。激活插件后点击设置→常规并更改 HTML 语言标签,即 en-US 等。