Skip to content

Commit 3ad7e8f

Browse files
[Added] add Japanese translation (locale: ja) (axios#74)
Co-authored-by: Jay <[email protected]>
1 parent 53a0ff5 commit 3ad7e8f

16 files changed

+1073
-0
lines changed

inert.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const krConfig = require("./kr.lang.js");
2727
const viConfig = require("./vi.lang.js");
2828
const faConfig = require("./fa.lang.js");
2929
const ruConfig = require("./ru.lang.js");
30+
const jaConfig = require("./ja.lang.js");
3031

3132
// List of languages
3233
const langs = [
@@ -108,6 +109,12 @@ const langs = [
108109
name: "Русский",
109110
prefix: "/ru/",
110111
config: ruConfig
112+
},
113+
{
114+
dir: "ltr",
115+
name: "日本語",
116+
prefix: "/ja/",
117+
config: jaConfig
111118
}
112119
];
113120

ja.lang.js

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/**
2+
* Configuration for the Japanese (ja) translation
3+
*/
4+
5+
module.exports = {
6+
// Language display name. MUST BE THE SAME AS IN [inert.config.js].custom.langs
7+
display: "日本語",
8+
prefix: "/ja/",
9+
dir: "ltr",
10+
lang: "ja",
11+
// `p` stands for `paragraph`. This will contain translations of full text blocks
12+
p: {
13+
headline: "ブラウザと Node.js のための Promise ベースの HTTP クライアント",
14+
subhead: `Axios は、ブラウザと Node.js のための、シンプルなプロミスベースの HTTP クライアントです。
15+
Axios は、非常に拡張性の高いインターフェイスを持つ小さなパッケージで、
16+
シンプルに使えるライブラリを提供します。`,
17+
},
18+
// `t` stands fot `translation`. This will contain translations of single words or phrases
19+
t: {
20+
"Get Started": 'Axios 入門',
21+
"View on GitHub": 'GitHub で表示',
22+
"Languages": '言語',
23+
"Open Source": 'オープンソース',
24+
"Contribute": 'コントリビュート (貢献)',
25+
"Source on GitHub": 'GitHub 上のソース',
26+
"Issues": 'イシュー',
27+
"Pull Requests": 'プルリクエスト',
28+
"Code of Conduct": '行動規範',
29+
"Fork on GitHub": 'GitHub でのフォーク',
30+
"Fork the Website": 'Web サイトをフォークする',
31+
"Create an Issue": 'イシューを作成する',
32+
"Next": '次へ',
33+
"Previous": '前へ',
34+
"Website Copy Right Footer": 'Web サイトの著作権フッター',
35+
"View On Github": 'GitHub で表示',
36+
"Axios Project Copy Right Footer": 'Axios プロジェクトの著作権フッター',
37+
"License Label Footer": 'ライセンスラベル フッター'
38+
},
39+
sidebar: [
40+
{
41+
type: "heading",
42+
text: "Axiom 入門",
43+
},
44+
{
45+
type: "link",
46+
href: "/docs/intro",
47+
text: "Axiom 入門",
48+
},
49+
{
50+
type: "link",
51+
href: "/docs/example",
52+
text: "使用例",
53+
},
54+
{
55+
type: "link",
56+
href: "/docs/post_example",
57+
text: "POST リクエスト",
58+
},
59+
{
60+
type: "heading",
61+
text: "Axios API",
62+
},
63+
{
64+
type: "link",
65+
href: "/docs/api_intro",
66+
text: "Axios API",
67+
},
68+
{
69+
type: "link",
70+
href: "/docs/instance",
71+
text: "Axios インスタンス",
72+
},
73+
{
74+
type: "link",
75+
href: "/docs/req_config",
76+
text: "リクエスト設定",
77+
},
78+
{
79+
type: "link",
80+
href: "/docs/res_schema",
81+
text: "レスポンス スキーマ",
82+
},
83+
{
84+
type: "link",
85+
href: "/docs/config_defaults",
86+
text: "デフォルト設定",
87+
},
88+
{
89+
type: "link",
90+
href: "/docs/interceptors",
91+
text: "インターセプター",
92+
},
93+
{
94+
type: "link",
95+
href: "/docs/handling_errors",
96+
text: "エラー処理",
97+
},
98+
{
99+
type: "link",
100+
href: "/docs/cancellation",
101+
text: "キャンセル",
102+
},
103+
{
104+
type: "link",
105+
href: "/docs/urlencoded",
106+
text: "URL-エンコードボディ",
107+
},
108+
{
109+
type: "heading",
110+
text: "その他",
111+
},
112+
{
113+
type: "link",
114+
href: "/docs/notes",
115+
text: "特記事項",
116+
},
117+
{
118+
type: "heading",
119+
text: "コントリビューター",
120+
},
121+
{
122+
type: "link",
123+
href: "https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md",
124+
text: "行動規範",
125+
},
126+
{
127+
type: "link",
128+
href: "https://github.com/axios/axios/blob/master/COLLABORATOR_GUIDE.md",
129+
text: "コントリビューター ガイド",
130+
},
131+
{
132+
type: "link",
133+
href: "https://github.com/axios/axios/blob/master/CONTRIBUTING.md",
134+
text: "Axios に貢献する"
135+
},
136+
{
137+
type: "link",
138+
href: "/docs/translating",
139+
text: "このドキュメントを翻訳する"
140+
}
141+
],
142+
};

posts/ja/api_intro.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: 'Axios API'
3+
description: 'Axios API リファレンス'
4+
prev_title: 'POST リクエスト'
5+
prev_link: '/docs/post_example'
6+
next_title: 'Axios インスタンス'
7+
next_link: '/docs/instance'
8+
---
9+
10+
関連する設定を `axios` に渡すことでリクエストを行うことができます。
11+
12+
##### axios(config)
13+
14+
```js
15+
// POST リクエストを送信する
16+
axios({
17+
method: 'post',
18+
url: '/user/12345',
19+
data: {
20+
firstName: 'Fred',
21+
lastName: 'Flintstone'
22+
}
23+
});
24+
```
25+
26+
```js
27+
// Node.js でのリモート画像を GET リクエスト
28+
axios({
29+
method: 'get',
30+
url: 'http://bit.ly/2mTM3nY',
31+
responseType: 'stream'
32+
})
33+
.then(function (response) {
34+
response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
35+
});
36+
```
37+
38+
##### axios(url[, config])
39+
40+
```js
41+
// GET リクエストの送信(デフォルト メソッド)
42+
axios('/user/12345');
43+
```
44+
45+
### リクエスト メソッドのエイリアス
46+
47+
使いやすいように、サポートされているすべてのリクエスト メソッドにエイリアスが提供されています。
48+
49+
##### axios.request(config)
50+
##### axios.get(url[, config])
51+
##### axios.delete(url[, config])
52+
##### axios.head(url[, config])
53+
##### axios.options(url[, config])
54+
##### axios.post(url[, data[, config]])
55+
##### axios.put(url[, data[, config]])
56+
##### axios.patch(url[, data[, config]])
57+
58+
######
59+
60+
エイリアス メソッドを使用する場合、`url`` method`、および `data` プロパティを設定で指定する必要はありません。

posts/ja/cancellation.md

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
title: 'Cancellation'
3+
prev_title: 'Handling Errors'
4+
prev_link: '/docs/handling_errors'
5+
next_title: 'URL-Encoding Bodies'
6+
next_link: '/docs/urlencoded'
7+
---
8+
9+
## AbortController
10+
11+
Starting from `v0.22.0` Axios supports [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) to cancel requests in fetch API way:
12+
13+
```js
14+
const controller = new AbortController();
15+
16+
axios.get('/foo/bar', {
17+
signal: controller.signal
18+
}).then(function(response) {
19+
//...
20+
});
21+
// cancel the request
22+
controller.abort()
23+
```
24+
25+
## CancelToken `deprecated`
26+
27+
You can also cancel a request using a *CancelToken*.
28+
29+
> The axios cancel token API is based on the withdrawn [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises).
30+
31+
> This API is deprecated since `v0.22.0` and shouldn't be used in new projects
32+
33+
You can create a cancel token using the `CancelToken.source` factory as shown below:
34+
35+
```js
36+
const CancelToken = axios.CancelToken;
37+
const source = CancelToken.source();
38+
39+
axios.get('/user/12345', {
40+
cancelToken: source.token
41+
}).catch(function (thrown) {
42+
if (axios.isCancel(thrown)) {
43+
console.log('Request canceled', thrown.message);
44+
} else {
45+
// handle error
46+
}
47+
});
48+
49+
axios.post('/user/12345', {
50+
name: 'new name'
51+
}, {
52+
cancelToken: source.token
53+
})
54+
55+
// cancel the request (the message parameter is optional)
56+
source.cancel('Operation canceled by the user.');
57+
```
58+
59+
You can also create a cancel token by passing an executor function to the `CancelToken` constructor:
60+
61+
```js
62+
const CancelToken = axios.CancelToken;
63+
let cancel;
64+
65+
axios.get('/user/12345', {
66+
cancelToken: new CancelToken(function executor(c) {
67+
// An executor function receives a cancel function as a parameter
68+
cancel = c;
69+
})
70+
});
71+
72+
// cancel the request
73+
cancel();
74+
```
75+
76+
> Note: you can cancel several requests with the same cancel token / signal.
77+
78+
During the transition period, you can use both cancellation APIs, even for the same request:
79+
80+
```js
81+
const controller = new AbortController();
82+
83+
const CancelToken = axios.CancelToken;
84+
const source = CancelToken.source();
85+
86+
axios.get('/user/12345', {
87+
cancelToken: source.token,
88+
signal: controller.signal
89+
}).catch(function (thrown) {
90+
if (axios.isCancel(thrown)) {
91+
console.log('Request canceled', thrown.message);
92+
} else {
93+
// handle error
94+
}
95+
});
96+
97+
axios.post('/user/12345', {
98+
name: 'new name'
99+
}, {
100+
cancelToken: source.token
101+
})
102+
103+
// cancel the request (the message parameter is optional)
104+
source.cancel('Operation canceled by the user.');
105+
// OR
106+
controller.abort(); // the message parameter is not supported
107+
```

posts/ja/config_defaults.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: 'デフォルト設定'
3+
prev_title: 'レスポンス スキーマ'
4+
prev_link: '/docs/res_schema'
5+
next_title: 'インターセプター'
6+
next_link: '/docs/interceptors'
7+
---
8+
9+
## デフォルト設定
10+
11+
すべてのリクエストに適用されるデフォルト設定を指定できます。
12+
13+
### グローバル Axios のデフォルト
14+
15+
```js
16+
axios.defaults.baseURL = 'https://api.example.com';
17+
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
18+
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
19+
```
20+
21+
### カスタム インスタンスのデフォルト
22+
23+
```js
24+
// インスタンスの作成時にデフォルト設定を指定する
25+
const instance = axios.create({
26+
baseURL: 'https://api.example.com'
27+
});
28+
29+
// インスタンスの作成後にデフォルト設定を変更する
30+
instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;
31+
```
32+
33+
### 設定の優先順位
34+
35+
設定は、優先順位をつけてマージされます。その順番は [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults.js#L28) にあるライブラリのデフォルト、そしてインスタンスの `defaults` プロパティ、最後にリクエストの `config` 引数の順になります。後者が前者よりも優先されます。以下はその例です。
36+
37+
```js
38+
// ライブラリが提供するデフォルトの設定を使用してインスタンスを作成します。
39+
// この時点では、タイムアウトの設定値はライブラリのデフォルトである `0` になっています。
40+
const instance = axios.create();
41+
42+
// ライブラリのデフォルトのタイムアウトを上書きします。
43+
// これで、このインスタンスを使用するすべてのリクエストは、タイムアウトする前に 2.5秒待機します。
44+
instance.defaults.timeout = 2500;
45+
46+
// 時間がかかることがわかっているため、このリクエストのタイムアウトをオーバーライドします。
47+
instance.get('/longRequest', {
48+
timeout: 5000
49+
});
50+
```

0 commit comments

Comments
 (0)