Versão Graph API

/{app-id}/translations

As strings do app traduzidas com as nossas ferramentas de tradução.

Leitura

GET /v25.0/{app-id}/translations?locale=fr_FR HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '/{app-id}/translations?locale=fr_FR',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
Bundle params = new Bundle();
params.putString("locale", "fr_FR");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{app-id}/translations",
    params,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
NSDictionary *params = @{
  @"locale": @"fr_FR",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{app-id}/translations"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Permissões

  • É necessário um token de acesso do app para retornar as traduções do app.

Modificadores

Nome Descrição Tipo

locale

Especifica o local do idioma a ser solicitado. Esse parâmetro é obrigatório ao ler esta borda.

enum{locale}

Campos

Nome Descrição Tipo

id

A identificação única de cada string.

string

translation

A string traduzida.

string

approval_status

O status de aprovação da string.

enum{auto-approved, approved, unapproved}

native_string

A string original que foi traduzida.

string

description

A descrição fornecida para a string.

string

Publicação

Você pode especificar novas strings a serem traduzidas no app com esta borda:

POST /v25.0/{app-id}/translations HTTP/1.1
Host: graph.facebook.com

native_strings=%5B%7B%22text%22%3A%22Test+String%22%2C+%22description%22%3A+%22This+is+a+test+string+for+an+app.%22%7D%5D
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post(
    '/{app-id}/translations',
    array (
      'native_strings' => '[{"text":"Test String", "description": "This is a test string for an app."}]',
    ),
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
Bundle params = new Bundle();
params.putString("native_strings", "[{\"text\":\"Test String\", \"description\": \"This is a test string for an app.\"}]");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{app-id}/translations",
    params,
    HttpMethod.POST,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
NSDictionary *params = @{
  @"native_strings": @"[{\"text\":\"Test String\", \"description\": \"This is a test string for an app.\"}]",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{app-id}/translations"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Permissões

  • É necessário um token de acesso do app para adicionar novas strings traduzidas ao app.

Campos

Nome Descrição Tipo

Vetor

Vetor

Vetor

Resposta

Se a solicitação for bem-sucedida, você receberá uma resposta simples com o número de strings adicionadas. Caso contrário, você receberá uma mensagem de erro.

Exclusão

É possível excluir strings traduzidas por meio desta operação:

<code-tabs-path language="phpsdk,iossdk,androidsdk,http" method="DELETE" param='{"native_hashes":"['hash1', 'hash2']"}' path="/{app-id}/translations" rendering_context="1" />

Permissões

  • É necessário um token de acesso do app para excluir strings traduzidas do app.

Campos

Nome Descrição Tipo

native_hashes

Uma matriz de hashes de cada string traduzida. O hash é um identificador único das strings e pode ser recuperado usando a tabela FQL translation.

string[]

Resposta

Se a solicitação for bem-sucedida, você receberá uma resposta simples com o número de strings excluídas. Caso contrário, você receberá uma mensagem de erro.