Currently we always load the US_en
SDK. At minimum it should load the one based on document lang
and also maybe allow overriding the locale at element level by introducing data-locale
on all amp-facebook-*
components.
--- Originally reported by @cvrlebg :
Hi, can you add new attribute for amp-facebook-like, something like data-locale where we can add language code like on FB documentation page: https://developers.facebook.com/docs/plugins/like-button#language?
This will be very useful for non-english sites.
Thanks!
@cvrlebg thanks for reporting. Updated the bug a it to cover all amp-facebook-*
components as all have the same issue.
/cc @ericlindley-g
Closed by #9310.
This still not OK. Not all languages exists in Facebook scripts, so, in my case the language is es_PE and Facebook return the default en_US. For spanish es_PE it must call the es_LA versi贸n (https://connect.facebook.net/es_LA/sdk.js NOT https://connect.facebook.net/es_PE/sdk.js)
@SashkaDev to get user's location we use navigator's language, which matches almost all Facebook's languages files.
But as per Facebook's docs, they support many ISO languages, which I understand is not all of them:
Locales and Languages Supported by Facebook
Languages on Facebook use the format ll_CC, where ll is a two-letter language code, and CC is a two-letter country code. For instance, en_US represents U.S. English. We support many ISO languages and country codes
There are two exceptions that do not follow the ISO standard: ar_AR and es_LA. We use these to denote umbrella locales for Arabic and Spanish. For Spanish, we support a few specialized localizations.
At Facebook's docs https://developers.facebook.com/docs/plugins/like-button?locale=en_US#language they say:
Supported locales are referenced in the Facebook Locales XML file.
But that file is missing :(
Someone has any ideias of what to do?
Yes, it is missing, but there are only 2 exceptions, and out there are lists (in many sites), also Wix have a pluggin that Maps locales to Facebook locales, with the exceptions.
https://github.com/wix/facebook-locales/blob/master/src/FacebookLocales.js
@SashkaDev, thanks. I'll try it when I get home tonight.
ps: sorry, didn't had time yet :(
This issue hasn't been updated in awhile. @aghassemi Do you have any updates?
The problem still exists. For example in Poland, where window.navigator.language gives exactly pl (not pl_PL). The window.navigator.languages[0] would be a much better suggestion, but it should check if it is a full language_COUNTRY pair.
Please change method dashToUnderline on this
function dashToUnderline(name) { if(2 === name.split('-').length) { return name.replace('-', '_'); }else { return name+'_'+name.toUpperCase(); } }
Because some language in window.navigator.language are different, ex. en_EN, pl, and your solution not connect with proper fb sdk.
LINK for education
https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language
/cc @nainar another candidate to consider.
p.s. we should expose data-locale
on all amp-facebook-*
components and only fallback to current state (e.g. sniffing navigation.language) if data-locale
is not provided
Happy to claim this.
Most helpful comment
Happy to claim this.