读取一种语言的译文
curl --request GET \
--url https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}import requests
url = "https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {method: 'GET'};
fetch('https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}");
var client = new RestClient(options);
var request = new RestRequest("");
var response = await client.GetAsync(request);
Console.WriteLine("{0}", response.Content);
val client = OkHttpClient()
val request = Request.Builder()
.url("https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}")
.get()
.build()
val response = client.newCall(request).execute()false{
"locale": "<string>",
"origin": {},
"entries": {},
"based_on_version": "<string>",
"updated_at": "<string>",
"revision": 123
}发现 Data App
读取一种语言的译文
读取一个 App 某种语言的完整译文 overlay,含 README。
GET
/
v1
/
data-apps
/
{app_id}
/
translations
/
{locale}
读取一种语言的译文
curl --request GET \
--url https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}import requests
url = "https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {method: 'GET'};
fetch('https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}");
var client = new RestClient(options);
var request = new RestRequest("");
var response = await client.GetAsync(request);
Console.WriteLine("{0}", response.Content);
val client = OkHttpClient()
val request = Request.Builder()
.url("https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}")
.get()
.build()
val response = client.newCall(request).execute()false{
"locale": "<string>",
"origin": {},
"entries": {},
"based_on_version": "<string>",
"updated_at": "<string>",
"revision": 123
}端点
GET https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/translations/{locale}
view=owner 使用作者视角解析,未发布的草稿也能被作者读到。
该语言没有译文时返回 404 translation-not-found。这在读取路径上是常见状态,按原文展示即可。
请求
路径参数
string
必填
App 引用,
app_<hex> 或 <namespace>/<app_name>。string
必填
语言代码,形如
en、en-US、zh-CN。查询参数
string
传
owner 切换到作者视角。示例请求
curl \
-H "Authorization: Bearer $BAZHUAYU_API_KEY" \
"https://api-datahub.bazhuayu.com/v1/data-apps/carol/probe-b/translations/en"
响应
200 成功
{
"data": {
"locale": "string",
"origin": "author",
"entries": {},
"based_on_version": "string",
"updated_at": "string",
"revision": 0
}
}
data 字段中,其内容如下。
string
必填
语言代码。
enum
必填
译文来源。 取值:
author / platform。object
译文条目,键是 manifest 中的路径,值是译文字符串或字符串数组。
string
译文基于的版本号。
string
必填
—
integer
必填
—
错误
| HTTP | code | category | 说明 |
|---|---|---|---|
| 401 | unauthorized | forbidden | 缺少或无效的 API Key。 |
| 404 | app-not-found | not_found | App 不存在、已改名,或对当前凭证不可见(私有 / 分享范围之外)。 |
| 404 | translation-not-found | not_found | 该语言没有译文。读取路径上这是常见状态,按原文展示即可。 |
{"error": {code, category, message, retryable}},见错误。
