Active
Project:
Facebook Comments Box
Version:
7.x-1.1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
26 Feb 2013 at 13:41 UTC
Updated:
26 Feb 2013 at 13:41 UTC
I suggest reading the HTTP_ACCEPT_LANGUAGE header to detect what languages the client would like.
e.g.
function facebook_comments_detect_language() {
$langcode = 'en_GB';
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
if (preg_match_all('@(?<=[, ]|^)([a-zA-Z-]+|\*)(?:;q=([0-9.]+))?(?:$|\s*,\s*)@', trim($_SERVER['HTTP_ACCEPT_LANGUAGE']), $matches, PREG_SET_ORDER)) {
$langcode = check_plain(str_replace('-', '_', $matches[0][1]));
}
}
return $langcode;
}
I'd also add a configurable option for the default locale.