Wordpress为Facebook SDK加载了错误的语言 [英] Wordpress loading wrong language for Facebook SDK

查看:101
本文介绍了Wordpress为Facebook SDK加载了错误的语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试使用帖子的网址将Facebook帖子嵌入到Wordpress中.除语言错误外,其他方法均能正常工作.它不是以英语显示,而是以阿拉伯语显示.

We are trying to embed Facebook posts into Wordpress using the URL of the post. This works fine except for the language is wrong. Instead of the language appearing in English, it is appearing in Arabic.

我相信我已将问题追溯到Wordpress加载的Facebook SDK.

I believe I have traced the problem to the Facebook SDK that is loaded by Wordpress.

这是Facebook说要添加到页面上的代码

This is the code that Facebook says to add to the page

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&amp;version=v2.5";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

这是Wordpress正在加载的内容

This is what Wordpress is loading

<div id="fb-root"></div>
<p><script>(function(d, s, id) {  
    var js, fjs = d.getElementsByTagName(s) [0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/ar_AR/sdk.js#xfbml=1&version=v2.3";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

我认为问题是Facebook连接网址中的"ar_AR",而不是"en_US".但是,我不知道该如何控制或在何处进行控制.

I believe that the issue is the "ar_AR" in the Facebook connection url instead of "en_US". However, I cannot figure out how or where that is controlled.

我检查了Wordpress中的语言选择,并且选择了英语.我尝试了没有插件的全新Wordpress 4.7安装,但问题仍然存在.

I checked the language selection in Wordpress and English is selected. I tried a fresh Wordpress 4.7 installation with no plugins and the problem still persists.

这是网站上以阿拉伯​​语显示的示例帖子.这也是我们要插入到Wordpress中以创建嵌入式帖子的内容.

Here is an example post that comes up in Arabic on the website. This is also what we are inserting into Wordpress to create the embedded post.

https://www.facebook.com/farahdhukai/videos/1217650958285047/

这里是阿拉伯语而不是英语的地方

Here is where it is appearing in Arabic instead of English

http://mvs.dev.clickharder.net/facebook-sdk-测试/

顶部嵌入是通过添加视频的URL来使用Wordpress嵌入功能.底部的嵌入是使用Facebook iframe嵌入方法进行测试.

The top embed is using the Wordpress embed feature by just adding the URL of the video. The bottom embed is using the Facebook iframe embed method for testing purposes.

我还没有弄清楚如何在Wordpress中禁用Facebook SDK,以便我自己插入它,或者如何将其从ar_AR更改为en_US.

I haven't figured out how to either disable the Facebook SDK within Wordpress so I can insert it myself or how to change it from ar_AR to en_US.

我在全新的Wordpress安装中搜索了所有对"Facebook"的引用,并且空手而归.我在Wordpress中找不到与此问题相关的"ar_AR"参考.

I have searched through every reference to "Facebook" in a fresh Wordpress install and have come up empty handed. I can't find a references for "ar_AR" within Wordpress that relates to this issue.

我们正在尝试避免使用嵌入帖子的iframe方法.这对我们的情况而言并不理想,因此对我们来说不是解决方案.

We are trying to avoid using the iframe method of embedding posts. It is not ideal for our situation so that is not a solution for us.

非常感谢您的帮助.

推荐答案

@CBroe提供了与我相同的解决方案.我添加了以下代码来替换参考.

@CBroe provided the same solution I went with. I added the following code to replace the reference.

add_filter( 'the_content', 'facebook_sdk_replace' );
function facebook_sdk_replace( $content ) {
    if ( is_single() ) {
        $content = str_replace("/ar_AR/", "/en_US/", $content);
    }
    return $content;
}

这篇关于Wordpress为Facebook SDK加载了错误的语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆