我的WordPress博客设置为nl_NL
. 这意味着我的bookly plugin 也显示在中nl_NL
.
在插件目录中有一个包含大量其他语言的文件夹languages。
我有三种不同语言的一页nl_NL
, de_DE
, en_EN
, 在此页面上,我希望预订插件以正确的语言显示。
我通过页面id从更改了页面语言nl_NL
到de_DE
通过function.php
, 但这没有任何效果。
function get_top_parent_page_id() {
global $post;
if ($post->ancestors) {
return end($post->ancestors);
} else {
return $post->ID;
}
}
function addLangMetaTag (){
$postLanguage = "nl_NL";
if (is_page()) {
$svPageID = get_top_parent_page_id(); // ID of parent page
if ($svPageID == "13040") { // ID of the "på svenska" page
$postLanguage = "de_DE";
}
echo "<meta http-equiv=\\"content-language\\" content=\\"" . $postLanguage . "\\">";
}
}
add_filter( \'wp_head\', \'addLangMetaTag\' );
function language_tagger_change_html_lang_tag() {
return "dir=\\"ltr\\" lang=\\"" .
language_tagger_determin_lang_tag() . "\\"";
}
function language_tagger_determin_lang_tag() {
$postLanguage = \'nl_NL\'; // default language
if (is_page()) {
$svPageID = get_top_parent_page_id(); // ID of parent page
if ($svPageID == "13040") { // ID of the "på svenska" page
$postLanguage = "de_DE";
}
}
return $postLanguage;
}
add_filter(\'language_attributes\',
\'language_tagger_change_html_lang_tag\');
我想它只会看WordPressconfig.php
define(\'WPLANG\', \'nl_NL\');
我也一直在阅读this post 也许我可以组合一些东西?