Skip to content

Commit

Permalink
docs: add examples for settings.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jy95 committed Sep 18, 2021
1 parent 6ebd94e commit be617a5
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 4 deletions.
20 changes: 20 additions & 0 deletions website/docs/commands/diff.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ This command generates a report (in JSON by default) that shows change(s) betwee
values={[
{ label: 'With two files', value: 'settings1', },
{ label: 'With three files', value: 'settings2', },
{ label: 'Settings.js', value: 'settings3', },
]
}>

Expand Down Expand Up @@ -262,4 +263,23 @@ npx @jy95/i18n-tools diff --settings "/absolutePath/to/settings2.json"

</TabItem>

<TabItem value="settings3">

```bash
npx @jy95/i18n-tools diff --settings "/absolutePath/to/settings3.js"
```

```js title="settings3.js"
module.exports = {
"filename":"diff_settings3-JSON",
"outputDir":"D:\\TEMP\\TEMP",
"outputFormat":"JSON",
"files":[
"D:\\TEMP\\fr_v0.json",
"D:\\TEMP\\fr_v1.json"
]
}
```
</TabItem>

</Tabs>
29 changes: 28 additions & 1 deletion website/docs/commands/export/export to_csv.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ simpleKey;[FR] not setted key;[NL] not setted key;[DE] not setted key
defaultValue="settings1"
values={[
{ label: 'Paths', value: 'settings1', },
{ label: 'Objects/Arrays', value: 'settings2', }
{ label: 'Objects/Arrays', value: 'settings2', },
{ label: 'Settings.js', value: 'settings3', }
]
}>

Expand Down Expand Up @@ -214,4 +215,30 @@ npx @jy95/i18n-tools export to_csv --settings "/absolutePath/to/settings2.json"
```
</TabItem>

<TabItem value="settings3">

```bash
npx @jy95/i18n-tools export to_csv --settings "/absolutePath/to/settings3.js"
```

```js title="settings3.js"
module.exports = {
files: ["fr", "nl", "de"].reduce(
(prev, curr) =>
Object.assign(prev, {
[curr.toUpperCase()]: `D:\\TEMP\\TEMP\\tests-for-export\\correct\\${curr}.json`,
}),
{}
),
columns: [
["FR", "French translation"],
["NL", "Dutch translation"],
["DE", "German translation"],
].map(([locale, label]) => ({ locale: locale, label: label })),
filename: "settings3-output",
outputDir: "D:\\TEMP\\TEMP"
};
```
</TabItem>

</Tabs>
6 changes: 3 additions & 3 deletions website/docs/commands/export/export to_xlsx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ This command helps you to turn them into a single xlsx file such as [this one](.
{ label: 'Paths', value: 'settings1', },
{ label: 'Objects/Arrays', value: 'settings2', },
{ label: 'Customize xlsx file', value: 'settings3', },
{ label: 'settings.js', value: 'settings4', },
{ label: 'Settings.js', value: 'settings4', },
]
}>

Expand Down Expand Up @@ -328,7 +328,7 @@ module.exports = async function(worksheet /*: Worksheet*/) {
npx @jy95/i18n-tools export to_xlsx --settings "/absolutePath/to/settings4.js"
```

```json title="settings4.js"
```js title="settings4.js"
// I keep in comments the stuff needed for the typings
// (So I can easily update this script in the future)
//import { Worksheet } from "exceljs";
Expand Down Expand Up @@ -421,7 +421,7 @@ module.exports = {
},
worksheetName: "Settings 4 - Worksheet",
filename: "settings4-output",
outputDir: "D:\\TEMP\\TEMP",
outputDir: "D:\\TEMP\\TEMP"
};
```

Expand Down
31 changes: 31 additions & 0 deletions website/docs/commands/import/import from_csv.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ This command helps you to turn this into several i18n json files :
values={[
{ label: 'Paths', value: 'settings1', },
{ label: 'Objects/Arrays', value: 'settings2', },
{ label: 'Settings.js', value: 'settings3', },
]
}>

Expand Down Expand Up @@ -202,4 +203,34 @@ npx @jy95/i18n-tools import from_csv --settings "/absolutePath/to/settings2.json

</TabItem>

<TabItem value="settings3">

```bash
npx @jy95/i18n-tools import from_csv --settings "/absolutePath/to/settings3.js"
```

```js title="settings3.js"
module.exports = {
input: "D:\\workspace\\i18n-tools\\test\\fixtures\\import-csv\\export-csv.csv",
columns: {
technical_key: "Technical Key",
locales: [
["FR", "French translation"],
["NL", "Dutch translation"],
["DE", "German translation"],
].reduce(
(prev, [locale, label]) =>
Object.assign(prev, {
[locale]: label,
}),
{}
),
},
locales: ["FR", "NL", "DE"],
outputDir: "D:\\TEMP\\TEMP\\tests-for-import",
suffix: "_settings3",
};
```
</TabItem>

</Tabs>
31 changes: 31 additions & 0 deletions website/docs/commands/import/import from_xlsx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ This command helps you to turn this into several i18n json files :
values={[
{ label: 'Paths', value: 'settings1', },
{ label: 'Objects/Arrays', value: 'settings2', },
{ label: 'Settings.js', value: 'settings3', },
]
}>

Expand Down Expand Up @@ -190,4 +191,34 @@ npx @jy95/i18n-tools import from_xlsx --settings "/absolutePath/to/settings2.jso

</TabItem>

<TabItem value="settings3">

```bash
npx @jy95/i18n-tools import from_xlsx --settings "/absolutePath/to/settings3.js"
```

```js title="settings3.js"
module.exports = {
input: "D:\\workspace\\i18n-tools\\test\\fixtures\\import-xlsx\\export-xlsx.xlsx",
columns: {
technical_key: "Technical Key",
locales: [
["FR", "French translation"],
["NL", "Dutch translation"],
["DE", "German translation"],
].reduce(
(prev, [locale, label]) =>
Object.assign(prev, {
[locale]: label,
}),
{}
),
},
locales: ["FR", "NL", "DE"],
outputDir: "D:\\TEMP\\TEMP\\tests-for-import",
suffix: "_settings3",
};
```
</TabItem>

</Tabs>

0 comments on commit be617a5

Please sign in to comment.