开发者

How to use FBJS to get the language preference of the user?

I'm modifying an existing FaceBook application. The FaceBook 开发者_开发技巧application is generated by another application, so I don't have much control over it. I can only add html/javascript.

My goal is to use FBJS to detect the current language setting of the user and display a different message depending on their language.

For example, if the user has their language setting set to Spanish, then I would like to show a message in Spanish on my FaceBook application.

How can I do this?


I don't think there's a way to do what you want with only HTML/JS changes.

I think the fastest way to do this is to use AJAX in FBJS to callback to your server. Server-side, grab /me from the Graph API. There's a locale field that tells you the user's language setting. Or do the Graph API server-side call when the page first loads and you can avoid AJAX altogether. The specifics of how you do this depend on what server-side language you're using.

The "right" way to do this is to let the translation community translate your site for you. Read this Internationalization doc for more info. If you're using using FBJS it sounds like this is a FBML app so you'd use some of these internationalization FBML tags.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜