Skip to content

Commit

Permalink
fix: aliyun service endpoint
Browse files Browse the repository at this point in the history
fix: #1035
  • Loading branch information
windingwind committed Dec 10, 2024
1 parent cdd7133 commit ae203ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ The secret format is `accessKeyId#accessKeySecret`

**Aliyun Translate**
Apply [here](https://www.aliyun.com/product/ai/base_alimt).
The secret format is `accessKeyId#accessKeySecret`.
The secret format is `accessKeyId#accessKeySecret#endpoint(optional)`.

> [Chinere Document](https://help.aliyun.com/document_detail/158269.html)
> The endpoint is the region of the service, default `https://mt.aliyuncs.com`. For `cn-hangzhou`, the endpoint is `mt.cn-hangzhou.aliyuncs.com`. See also [here](https://help.aliyun.com/zh/machine-translation/developer-reference/api-alimt-2018-10-12-endpoint?spm=a2c4g.11186623.help-menu-30396.d_4_1_0.6c702fa7WlNkX1).
> [Chinese Document](https://help.aliyun.com/document_detail/158269.html)
**Baidu Translate**
Apply [here](https://fanyi-api.baidu.com/product/11).
Expand Down
3 changes: 2 additions & 1 deletion src/modules/services/aliyun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default <TranslateTaskProcessor>async function (data) {
const params = data.secret.split("#");
const accessKeyId = params[0];
const accessKeySecret = params[1];
const endpoint = params[2] || "https://mt.aliyuncs.com/";

function languageCode(str: string) {
str = str.toLowerCase();
Expand Down Expand Up @@ -35,7 +36,7 @@ export default <TranslateTaskProcessor>async function (data) {
await hmacSha1Digest(stringToSign, `${accessKeySecret}&`),
);

const xhr = await Zotero.HTTP.request("POST", "https://mt.aliyuncs.com/", {
const xhr = await Zotero.HTTP.request("POST", endpoint, {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
Expand Down

0 comments on commit ae203ed

Please sign in to comment.