Phiên bản API Đồ thị

/{app-id}/translations

Chuỗi trong ứng dụng này đã được dịch bằng các công cụ dịch của chúng tôi.

Đọc

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
}];

Quyền

  • Bạn phải có mã truy cập ứng dụng thì mới trả về được bản dịch cho ứng dụng đó.

Thông số sửa đổi

Tên Mô tả Loại

locale

Chỉ định địa phương của ngôn ngữ sẽ yêu cầu. Đây là thông số bắt buộc khi đọc cạnh này.

enum{địa phương}

Trường

Tên Mô tả Loại

id

ID duy nhất của từng chuỗi.

string

translation

Chuỗi đã dịch.

string

approval_status

Trạng thái phê duyệt của chuỗi.

enum{auto-approved, approved, unapproved}

native_string

Chuỗi gốc đã dịch.

string

description

Phần mô tả được cung cấp của chuỗi.

string

Đăng

Bạn có thể chỉ định các chuỗi mới cần dịch cho ứng dụng của mình bằng cạnh này:

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
}];

Quyền

  • Bạn phải có mã truy cập ứng dụng thì mới thêm được chuỗi bản dịch mới cho ứng dụng đó.

Trường

Tên Mô tả Loại

Véc-tơ

Véc-tơ

Véc-tơ

Phản hồi

Nếu thành công, bạn sẽ nhận được phản hồi thuần túy về số lượng chuỗi đã thêm. Nếu không, hệ thống sẽ trả về thông báo lỗi.

Xóa

Bạn có thể xóa chuỗi bản dịch bằng thao tác sau:

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

Quyền

  • Bạn phải có mã truy cập ứng dụng thì mới xóa được chuỗi bản dịch khỏi ứng dụng đó.

Trường

Tên Mô tả Loại

native_hashes

Một mảng gồm các hash của từng chuỗi bản dịch. Hash là thông tin nhận dạng duy nhất của mỗi chuỗi. Bạn có thể truy xuất hash bằng bảng FQL translation.

string[]

Phản hồi

Nếu thành công, bạn sẽ nhận được phản hồi thuần túy về số lượng chuỗi đã xóa. Nếu không, hệ thống sẽ trả về thông báo lỗi.