Skip to content

Commit 38c750b

Browse files
soetzjasonsaayman
andauthored
French translation (axios#63)
* [Updated] use new inert package name in README.md too * [Updated] the set of translations so that it contains all translated terms * [Added] French translation * [Fixed] small typo Co-authored-by: Jay <[email protected]>
1 parent 5b7c239 commit 38c750b

19 files changed

+1103
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The documentation page was built using [`inert static site generator`](https://g
88
To compile the documentation page, one must first install the inert CLI:
99

1010
```bash
11-
npm i -g inert-cli # yarn global add inert-cli
11+
npm i -g inert-ssg # yarn global add inert-ssg
1212
```
1313

1414
Now, open a terminal and run the following command:

en.lang.js

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ module.exports = {
2323
"Open Source": undefined,
2424
"Contribute": undefined,
2525
"Source on GitHub": undefined,
26+
"Issues": undefined,
27+
"Pull Requests": undefined,
28+
"Code of Conduct": undefined,
2629
"Fork on GitHub": undefined,
2730
"Fork the Website": undefined,
2831
"Create an Issue": undefined,

fr.lang.js

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/**
2+
* Configuration for the french translation
3+
*/
4+
5+
module.exports = {
6+
display: "Français",
7+
prefix: "/fr/",
8+
dir: "ltr",
9+
lang: "fr",
10+
p: {
11+
headline: "Client HTTP basé sur les promesses pour navigateur et node.js",
12+
subhead: `Axios est un client HTTP simple basé sur les promesses compatible
13+
avec le navigateur et node.js.
14+
Il propose une librairie facile à utiliser et à étendre, le tout
15+
dans un tout petit package.`,
16+
},
17+
t: {
18+
"Get Started": "Démarrer",
19+
"View on GitHub": "Voir sur GitHub",
20+
"Languages": "Langues",
21+
"Open Source": "Open source",
22+
"Contribute": "Contribuer",
23+
"Source on GitHub": "Source sur GitHub",
24+
"Issues": undefined,
25+
"Pull Requests": "Pull requests",
26+
"Code of Conduct": "Code de conduite",
27+
"Fork on GitHub": "Forker sur GitHub",
28+
"Fork the Website": "Forker ce site",
29+
"Create an Issue": "Créer une issue",
30+
"Next": "Suivant",
31+
"Previous": "Précédent",
32+
"Website Copy Right Footer": `Ce site : Copyright © 2020-aujourd’hui John Jakob "Jake" Sarjeant. Utilisé avec permission.`,
33+
"View On Github": "Voir sur GitHub",
34+
"Axios Project Copy Right Footer": "Le projet Axios : Copyright © 2014-aujourd’hui Matt Zabriskie.",
35+
"License Label Footer": "Sous"
36+
},
37+
sidebar: [
38+
{
39+
type: "heading",
40+
text: "Démarrer",
41+
},
42+
{
43+
type: "link",
44+
href: "/docs/intro",
45+
text: "Introduction",
46+
},
47+
{
48+
type: "link",
49+
href: "/docs/example",
50+
text: "Exemple",
51+
},
52+
{
53+
type: "link",
54+
href: "/docs/post_example",
55+
text: "Requêtes POST",
56+
},
57+
{
58+
type: "heading",
59+
text: "API Axios",
60+
},
61+
{
62+
type: "link",
63+
href: "/docs/api_intro",
64+
text: "API Axios",
65+
},
66+
{
67+
type: "link",
68+
href: "/docs/instance",
69+
text: "L’instance Axios",
70+
},
71+
{
72+
type: "link",
73+
href: "/docs/req_config",
74+
text: "Configuration de requête",
75+
},
76+
{
77+
type: "link",
78+
href: "/docs/res_schema",
79+
text: "Schéma de réponse",
80+
},
81+
{
82+
type: "link",
83+
href: "/docs/config_defaults",
84+
text: "Configuration par défaut",
85+
},
86+
{
87+
type: "link",
88+
href: "/docs/interceptors",
89+
text: "Intercepteurs",
90+
},
91+
{
92+
type: "link",
93+
href: "/docs/handling_errors",
94+
text: "Gestion des erreurs",
95+
},
96+
{
97+
type: "link",
98+
href: "/docs/cancellation",
99+
text: "Annuler une requête",
100+
},
101+
{
102+
type: "link",
103+
href: "/docs/urlencoded",
104+
text: "URL-Encoder le contenu d’une requête",
105+
},
106+
{
107+
type: "heading",
108+
text: "Autre",
109+
},
110+
{
111+
type: "link",
112+
href: "/docs/notes",
113+
text: "Notes",
114+
},
115+
{
116+
type: "heading",
117+
text: "Contributeurs",
118+
},
119+
{
120+
type: "link",
121+
href: "https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md",
122+
text: "Code de conduite",
123+
},
124+
{
125+
type: "link",
126+
href: "https://github.com/axios/axios/blob/master/COLLABORATOR_GUIDE.md",
127+
text: "Guide du collaborateur",
128+
},
129+
{
130+
type: "link",
131+
href: "https://github.com/axios/axios/blob/master/CONTRIBUTING.md",
132+
text: "Contribuer à Axios"
133+
},
134+
{
135+
type: "link",
136+
href: "/docs/translating",
137+
text: "Traduire cette documentation"
138+
}
139+
],
140+
};

inert.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const ukConfig = require("./uk.lang.js");
2121
const ptBRConfig = require("./ptBR.lang.js");
2222
const kuConfig = require("./ku.lang.js");
2323
const esConfig = require('./es.lang.js');
24+
const frConfig = require("./fr.lang.js");
2425
const trConfig = require("./tr.lang.js");
2526
const krConfig = require("./kr.lang.js");
2627
const viConfig = require("./vi.lang.js");
@@ -71,6 +72,12 @@ const langs = [
7172
prefix: "/es/",
7273
config: esConfig,
7374
},
75+
{
76+
dir: "ltr",
77+
name: "Français",
78+
prefix: "/fr/",
79+
config: frConfig,
80+
},
7481
{
7582
dir: "ltr",
7683
name: "Türkçe",

posts/en/req_config.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ These are the available config options for making requests. Only the `url` is re
5858
},
5959

6060
// `data` is the data to be sent as the request body
61-
// Only applicable for request methods 'PUT', 'POST', 'DELETE , and 'PATCH'
61+
// Only applicable for request methods 'PUT', 'POST', 'DELETE', and 'PATCH'
6262
// When no `transformRequest` is set, must be of one of the following types:
6363
// - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
6464
// - Browser only: FormData, File, Blob

posts/fr/api_intro.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: 'API Axios'
3+
description: 'Le référentiel de l’API Axios'
4+
prev_title: 'Requêtes POST'
5+
prev_link: '/fr/docs/post_example'
6+
next_title: 'L’instance Axios'
7+
next_link: '/fr/docs/instance'
8+
---
9+
10+
Les requêtes peuvent être faites en passant la configuration correspondante à `axios()`.
11+
12+
##### axios(config)
13+
14+
```js
15+
// Envoi d’une requête POST.
16+
axios({
17+
method: 'post',
18+
url: '/user/12345',
19+
data: {
20+
firstName: 'Fred',
21+
lastName: 'Pierrafeu'
22+
}
23+
});
24+
```
25+
26+
```js
27+
// Requête GET pour une image distante avec node.js.
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+
// Envoyer une requête GET (c’est la méthode par défaut).
42+
axios('/user/12345');
43+
```
44+
45+
### Alias des méthodes de requête
46+
47+
Pour plus de simplicité, des alias correspondant à toutes les méthodes supportées existent.
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+
> **Note :** lorsque vous utilisez des alias de méthodes, les champs `url`, `method` et `data` n’ont pas besoin d’être spécifiés dans la configuration.

posts/fr/cancellation.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
title: 'Annuler une requête'
3+
prev_title: 'Gestion des erreurs'
4+
prev_link: '/fr/docs/handling_errors'
5+
next_title: 'URL-Encoder le contenu d’une requête'
6+
next_link: '/fr/docs/urlencoded'
7+
---
8+
9+
## AbortController
10+
11+
À partir de sa `v0.22.0` Axios supporte [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) afin d’annuler des requêtes à la façon de l’API fetch :
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+
// annule la requête
22+
controller.abort()
23+
```
24+
25+
## CancelToken `déprécié`
26+
27+
Vous pouvez aussi annuler une requête à l’aide d’un *CancelToken* (jeton d’annulation).
28+
29+
> L’API des jetons d’annulation d’Axios est basée sur la [proposition permettant d’annuler des promesses](https://github.com/tc39/proposal-cancelable-promises) qui a depuis été retirée.
30+
31+
> Cette API est dépréciée depuis la `v0.22.0` et ne devrait pas être utilisée pour de nouveaux projets
32+
33+
Vous pouvez créer un jeton d’annulation à l’aide de la factory `CancelToken.source` comme ce qui suit :
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+
// gestion de l’erreur
46+
}
47+
});
48+
49+
axios.post('/user/12345', {
50+
name: 'new name'
51+
}, {
52+
cancelToken: source.token
53+
})
54+
55+
// annule la requête (le message est optionnel)
56+
source.cancel('Operation canceled by the user.');
57+
```
58+
59+
Vous pouvez aussi créer un jeton d’annulation en passant une fonction `executor()` au constructeur de `CancelToken` :
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+
// la fonction executor reçoit une fonction d’annulation comme paramètre
68+
cancel = c;
69+
})
70+
});
71+
72+
// annule la requête
73+
cancel();
74+
```
75+
76+
> **Note :** vous pouvez annuler plusieurs requêtes différentes avec le même jeton/signal d’annulation.
77+
78+
Pendant la période de transition, vous pouvez utiliser n’importe laquelle des APIs d’annulation, y compris pour une même requête :
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+
// gestion de l’erreur
94+
}
95+
});
96+
97+
axios.post('/user/12345', {
98+
name: 'new name'
99+
}, {
100+
cancelToken: source.token
101+
})
102+
103+
// annule la requête (le message est optionnel)
104+
source.cancel('Operation canceled by the user.');
105+
// OU
106+
// annule la requête (le paramètre de message n’est pas supporté)
107+
controller.abort();
108+
```

0 commit comments

Comments
 (0)