简体   繁体   中英

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM