Intl.getTranslations

From Facebook Developer Wiki

Jump to: navigation, search

Contents

Description

Returns an array of strings from your application that you submitted for translation. This call returns the original native strings, the best (or all) translations of native strings into a given locale, whether the string has been approved, and by whom.

By default, the translation for a given string that gets returned is the current best translation, as it appears in the Facebook Translations application database. The translation was approved either automatically by the Translations application or was manually approved by you, another developer of your application, or a translator with whom you have a contract.

If there is no such translation, then the native string doesn't get returned.

You do not have to pass a session key with this method. However, you must include your application secret (or session secret -- see below).

Parameters

RequiredNameTypeDescription
required api_key string The application key associated with the calling application. If you specify the API key in your client, you don't need to pass it with every call.
sig string An MD5 hash of the current request and your secret key, as described in the How Facebook Authenticates Your Application. Facebook computes the signature for you automatically.
v string This must be set to 1.0 to use this version of the API. If you specify the version in your client, you don't need to pass it with every call.
optional format string The desired response format, which can be either XML or JSON. (Default value is XML.)
callback string Name of a function to call. This is primarily to enable cross-domain JavaScript requests using the <script> tag, also known as JSONP, and works with both the XML and JSON formats. The function will be called with the response passed as the parameter.
locale string The locale from where you are retrieving the translated strings. To return translated strings from every locale where someone has translated your application, specify all for locale (however, this is not recommended for performance reasons). Locales are of the format ll_CC, where ll is a two-letter language code (in lowercase), and CC is a two-letter country code (in uppercase). For a list of locales Facebook supports, see Facebook Locales. If the default is used, then only the native strings get returned. (Default value is en_US.)
all bool When true, this call returns every translation for every native string. When false, this call returns the best translation for every native string. (Default value is false.)

Example Requests

The following request returns the best translations for the Spanish locale in Spain. See the first XML response below for results.

$facebook->api_client->intl_getTranslations('es_ES', false);


The following request returns the native strings for an application. See the second XML response below for results.

$facebook->api_client->intl_getTranslations('en_US','');


The following request returns all the translations (whether approved or unapproved) for every native string in an application. See the third XML response below for results.

$facebook->api_client->intl_getTranslations('all', true);

Response

This method returns an array of locales, which maps to a numerically indexed associative array of native strings, which in turn maps to a list of arrays (containing the translation, approval status, and description for each string). The approval status is one of:

  • auto-approved: Automatically approved by our system, based on votes.
  • approved: Manually approved by you, another developer of your application, or an authorized translator.
  • unapproved: Not approved in any manner.

Note: Descriptions are tied to native strings, not to translations. This is to disambiguate translations for the same native string that were submitted for different descriptions of that string.

If locale is not defined, then only the native strings get returned.

Otherwise, an error is returned.

Example Return XML

<?xml version="1.0" encoding="UTF_8"?> <intl_getTranslations_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema_instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true"> <locale_data> <locale>es_ES</locale> <strings list="true"> <locale_string> <native_string>Basic Information</native_string> <translations list="true"> <translation_info> <translation>Información Básica</translation> <status>auto-approved</status> <description>User's basic information</description> </translation_info> </translations> </locale_string> </strings> </locale_data> </intl_getTranslations_response>


<?xml version="1.0" encoding="UTF_8"?> <intl_getTranslations_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema_instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true"> <locale_data> <locale>en_US</locale> <strings list="true"> <locale_string> <native_string>Welcome to Science of the Web metrics.</native_string> <translations list="true"> <translation_info> <description/> </translation_info> </translations> </locale_string> <locale_string> <native_string>Basic Information</native_string> <translations list="true"> <translation_info> <description>User's basic information</description> </translation_info> </translations> </locale_string> <locale_string> <native_string>Status</native_string> <translations list="true"> <translation_info> <description>State of a process</description> </translation_info> </translations> </locale_string> </strings> </locale_data> </intl_getTranslations_response>


<?xml version="1.0" encoding="UTF_8"?> <intl_getTranslations_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema_instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true"> <locale_data> <locale>ca_ES</locale> <strings list="true"/> </locale_data> <locale_data> <locale>cs_CZ</locale> <strings list="true"/> </locale_data> <locale_data> <locale>cy_GB</locale> <strings list="true"/> </locale_data> <locale_data> <locale>da_DK</locale> <strings list="true"/> </locale_data> <locale_data> <locale>de_DE</locale> <strings list="true"/> </locale_data> <locale_data> <locale>en_US</locale> <strings list="true"/> </locale_data> <locale_data> <locale>es_LA</locale> <strings list="true"/> </locale_data> <locale_data> <locale>es_ES</locale> <strings list="true"> <locale_string> <native_string>Basic Information</native_string> <translations list="true"> <translation_info> <translation>Información Básica</translation> <status>auto-approved</status> <description>User's basic information</description> </translation_info> </translations> </locale_string> <locale_string> <native_string>Status</native_string> <translations list="true"> <translation_info> <translation>Estatus</translation> <status>unapproved</status> <description>State of a process</description> </translation_info> </translations> </locale_string> </strings> </locale_data> <locale_data> <locale>fi_FI</locale> <strings list="true"/> </locale_data> <locale_data> <locale>fr_FR</locale> <strings list="true"/> </locale_data> <locale_data> <locale>hu_HU</locale> <strings list="true"/> </locale_data> <locale_data> <locale>it_IT</locale> <strings list="true"/> </locale_data> <locale_data> <locale>ja_JP</locale> <strings list="true"/> </locale_data> <locale_data> <locale>ko_KR</locale> <strings list="true"/> </locale_data> <locale_data> <locale>nb_NO</locale> <strings list="true"/> </locale_data> <locale_data> <locale>nl_NL</locale> <strings list="true"/> </locale_data> <locale_data> <locale>pl_PL</locale> <strings list="true"> <locale_string> <native_string>Basic Information</native_string> <translations list="true"> <translation_info> <translation>Informacja podstawowa</translation> <status>approved</status> <description>User's basic information</description> </translation_info> <translation_info> <translation>Podstawowe informacje</translation> <status>unapproved</status> <description>User's basic information</description> </translation_info> </translations> </locale_string> </strings> </locale_data> <locale_data> <locale>pt_BR</locale> <strings list="true"/> </locale_data> <locale_data> <locale>pt_PT</locale> <strings list="true"/> </locale_data> <locale_data> <locale>ro_RO</locale> <strings list="true"/> </locale_data> <locale_data> <locale>ru_RU</locale> <strings list="true"/> </locale_data> <locale_data> <locale>sk_SK</locale> <strings list="true"/> </locale_data> <locale_data> <locale>sl_SI</locale> <strings list="true"/> </locale_data> <locale_data> <locale>sv_SE</locale> <strings list="true"/> </locale_data> <locale_data> <locale>th_TH</locale> <strings list="true"/> </locale_data> <locale_data> <locale>tr_TR</locale> <strings list="true"/> </locale_data> <locale_data> <locale>zh_CN</locale> <strings list="true"/> </locale_data> <locale_data> <locale>zh_HK</locale> <strings list="true"/> </locale_data> <locale_data> <locale>zh_TW</locale> <strings list="true"/> </locale_data> <locale_data> <locale>af_ZA</locale> <strings list="true"/> </locale_data> <locale_data> <locale>bn_IN</locale> <strings list="true"/> </locale_data> <locale_data> <locale>bg_BG</locale> <strings list="true"/> </locale_data> <locale_data> <locale>hr_HR</locale> <strings list="true"/> </locale_data> <locale_data> <locale>en_GB</locale> <strings list="true"> </strings> </locale_data> <locale_data> <locale>fr_CA</locale> <strings list="true"/> </locale_data> <locale_data> <locale>el_GR</locale> <strings list="true"/> </locale_data> <locale_data> <locale>hi_IN</locale> <strings list="true"/> </locale_data> <locale_data> <locale>id_ID</locale> <strings list="true"/> </locale_data> <locale_data> <locale>lt_LT</locale> <strings list="true"/> </locale_data> <locale_data> <locale>ms_MY</locale> <strings list="true"/> </locale_data> <locale_data> <locale>pa_IN</locale> <strings list="true"/> </locale_data> <locale_data> <locale>sr_RS</locale> <strings list="true"/> </locale_data> <locale_data> <locale>tl_PH</locale> <strings list="true"/> </locale_data> <locale_data> <locale>ta_IN</locale> <strings list="true"/> </locale_data> <locale_data> <locale>te_IN</locale> <strings list="true"/> </locale_data> <locale_data> <locale>ml_IN</locale> <strings list="true"/> </locale_data> <locale_data> <locale>vi_VN</locale> <strings list="true"/> </locale_data> <locale_data> <locale>ar_AR</locale> <strings list="true"/> </locale_data> <locale_data> <locale>he_IL</locale> <strings list="true"/> </locale_data> </intl_getTranslations_response>

Error Codes

CodeDescription
100 Invalid parameter.
170 An unsupported or incorrect locale was supplied. See Facebook Locales for the list of valid locales.

Notes

  • Native strings are untranslated strings in your application's native language. At this time, the Translations application only supports applications that use English as the native language.
  • You can call this method using a session secret, and not the application secret (for example, for a Facebook Connect site or desktop application).

See Also

reference