我正在修改现有的 Facebook 应用程序。FaceBook 应用程序是由另一个应用程序生成的,因此我对它没有太多控制权。我只能添加 html/javascript。
我的目标是使用 FBJS 来检测用户的当前语言设置,并根据他们的语言显示不同的消息。
例如,如果用户将他们的语言设置设置为西班牙语,那么我想在我的 Facebook 应用程序上显示一条西班牙语消息。
我怎样才能做到这一点?
我正在修改现有的 Facebook 应用程序。FaceBook 应用程序是由另一个应用程序生成的,因此我对它没有太多控制权。我只能添加 html/javascript。
我的目标是使用 FBJS 来检测用户的当前语言设置,并根据他们的语言显示不同的消息。
例如,如果用户将他们的语言设置设置为西班牙语,那么我想在我的 Facebook 应用程序上显示一条西班牙语消息。
我怎样才能做到这一点?
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.