## 翻譯 API 規格
我們預計提供兩支 API,包括:
### 1. 查詢語言代碼
* **Path**: `{host}/api/v1/lang_code`
* **Method**: `GET`
* **Output**:
```json
{
"zh_tw": 0,
"en": 1,
"jp": 2,
"ko": 3,
"th": 4,
"zh_cn": 5
}
```
---
### 2. 翻譯
* **Path**: `{host}/api/v1/translate?from_lang=&to_lang=&to_lang=`
* **Method**: `POST`
* **Content-Type**: `text/plain; charset=utf-8`
* **Parameters**:
* `use_cache` (boolean, 選填,default:True): 是否使用快取功能。
* `target_lang` (List[int], 必填): 目標語言的 `lang_code`。可以多次指定以傳遞多個值。
* **Input**:
* **URL**: `{host}/api/v1/translate/?use_cache=true&target_lang=1&target_lang=2`
* **Body**:
```html
<div>
<span style="font-size:14px;">
<span style="font-family:Microsoft JhengHei;">
今天您將抵達阿拉斯加州第二大城市費爾班克斯(Fairbanks),優越的地理位置及氣候環境使這裡享有“極光之都”的美譽。
抵達後入住酒店休息(阿拉斯加各酒店下午16:00之後可以辦理入住手續)。
</span>
</span>
<br />
</div>
<div>
<span style="font-size:14px;">
<span style="font-family:Microsoft JhengHei;">
夜幕降臨時,計畫於22:00乘坐<strong>北極光班車</strong>前往北極光觀測木屋。
專業的極光導遊將向您介紹北極光的相關知識,相機參數調試及北極光拍攝技巧,以助您拍到精彩的極光照片。
木屋內提供免費的熱飲,咖啡以及北極光監測螢幕,您可以在此溫暖守候北極光。
預計於次日淩晨02:00抵達酒店休息。
</span>
</span>
</div>
```
* **Output**:
```json
{
"request_id": "5d6683dc4e129548b8925982b095eb0aae9928ad7c77433b73b701b2857d3151",
"period_seconds": 2.883633613586426,
"output": {
"2": "<div><span style=\"font-size:14px;\"><span style=\"font-family:Microsoft JhengHei;\">今日はアラスカ州第二の都市フェアバンクス(Fairbanks)に到着します。優れた地理的位置と気候環境により、 ここは「オーロラの都」としての名声を誇っています。到着後はホテルにチェックインし、休息してください(アラスカの各ホテルは午後16:00以降にチェックイン手続きが可能です)。</span></span><br/> </div>\n<div><span style=\"font-size:14px;\"><span style=\"font-family:Microsoft JhengHei;\">夜が訪れたら、22:00に乗車する予定です。<strong>オーロラシャトル</strong>オーロラ観測のためのログキャビンに向かいます。専門のオーロラガイドがオーロラに関する知識、カメラ設定の調整、オーロラ撮影のテクニックを紹介し、素晴らしいオーロラの写真を撮る手助けをします。ログキャビン内では無料の ホットドリンク、コーヒー、オーロラモニターが提供され、温かい場所でオーロラを待つことができます。翌朝02:00にホテルに到着し、休息する予定です。</span></span></div>\n",
"1": "<div><span style=\"font-size:14px;\"><span style=\"font-family:Microsoft JhengHei;\">Today you will arrive in Fairbanks, the second largest city in Alaska. Its superior geographical location and climate conditions earn it the reputation of being the 'Capital of the Aurora.' After arrival, check into the hotel and rest (check-in at Alaska hotels is available after 16:00).</span></span><br/> </div>\n<div><span style=\"font-size:14px;\"><span style=\"font-family:Microsoft JhengHei;\">As night falls, plan to take the<strong>Aurora Shuttle</strong>to the Aurora Observation Cabin. A professional Aurora guide will introduce you to relevant knowledge about the Aurora, camera parameter adjustments, and photographing techniques to help you capture stunning photos of the Aurora. The cabin offers free hot drinks, coffee, and an Aurora monitoring screen, where you can warm up and wait for the Aurora. It is expected to arrive back at the hotel for rest at 02:00 the next day.</span></span></div>"
},
"rDesc": "Success!",
"rCode": "0000"
}
```
- request_id: 此次請求的Id
- period_secodes: 請求花費的時間
- output: 翻譯的結果
- rDesc: 請求狀態描述
- rCode:請求狀態代碼
---