Question:

I would like to develop a multi-language app so that for people using different locale, different language text strings will be used in the app.

How can I determine the language used by the current user in browsing Facebook pages when they first visit my app (i.e. before they are authenticated and grant permission to my app)?

 

 

Answer:

Appreciate if you can like this page if you find it useful! - Click "Like"

When the user access your canvas app via http://apps.facebook.com/yourappname, Facebook will send/redirect the request to your canvas URL with a signed request.

Content of a sample signed request that is received for a user that has not logged in to Facebook shown below:

Array  (
      [algorithm] => HMAC-SHA256
      [issued_at] => 1308242640
      [user] => Array (
              [country] => hk
              [locale] => en_US
              [age] => Array (
                      [min] => 0
                      [max] => 12
                      )
                )
)  

** More information like user_id will be included if the user has authorized your app before.

So, by using the "locale" field, you can determine the locale that is currently used by the user in browsing Facebook pages.

 

Find my FAQ on Facebook Development useful? Download the PDF for all the FAQs HERE!