Reload Facebook SDK for multi-lingual Like button
// Remove all Facebook elements and instances
$$('#facebook-jssdk, #fb-root, .fb-share-button').remove();
delete FB;
// Re-append Facebook elements ready for script re-init
$('body').append("div")
.attr("id", "fb-root");
$('#facebook').append("div")
.attr("class", "fb-share-button")
.attr("data-href", "YOUR_URL")
.attr("data-width", "120px")
.attr("data-type", "button");
// Attach FB Init callback to window
window.fbAsyncInit = function() {
FB.init({
appId : FACEBOOK_APP_ID,
xfbml : true,
version : 'v2.0'
});
};
// (Re-)load the Facebook SDK with current language
// LANGUAGE_REGION might be "en_GB" or "es_LA"
(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/" + LANGUAGE_REGION + "/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
Written by Effisfor
Related protips
2 Responses
Thanks man!
over 1 year ago
·
Thank you!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Facebook
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#