From be617a58c590cec1278a74f405376ed4334d21a3 Mon Sep 17 00:00:00 2001 From: jy95 Date: Sat, 18 Sep 2021 11:33:22 +0200 Subject: [PATCH] docs: add examples for settings.js --- website/docs/commands/diff.mdx | 20 ++++++++++++ .../docs/commands/export/export to_csv.mdx | 29 ++++++++++++++++- .../docs/commands/export/export to_xlsx.mdx | 6 ++-- .../docs/commands/import/import from_csv.mdx | 31 +++++++++++++++++++ .../docs/commands/import/import from_xlsx.mdx | 31 +++++++++++++++++++ 5 files changed, 113 insertions(+), 4 deletions(-) diff --git a/website/docs/commands/diff.mdx b/website/docs/commands/diff.mdx index ebf85a9..a7f3272 100644 --- a/website/docs/commands/diff.mdx +++ b/website/docs/commands/diff.mdx @@ -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', }, ] }> @@ -262,4 +263,23 @@ npx @jy95/i18n-tools diff --settings "/absolutePath/to/settings2.json" + + +```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" + ] +} +``` + + \ No newline at end of file diff --git a/website/docs/commands/export/export to_csv.mdx b/website/docs/commands/export/export to_csv.mdx index a3cd2e4..8d8ca1b 100644 --- a/website/docs/commands/export/export to_csv.mdx +++ b/website/docs/commands/export/export to_csv.mdx @@ -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', } ] }> @@ -214,4 +215,30 @@ npx @jy95/i18n-tools export to_csv --settings "/absolutePath/to/settings2.json" ``` + + +```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" +}; +``` + + \ No newline at end of file diff --git a/website/docs/commands/export/export to_xlsx.mdx b/website/docs/commands/export/export to_xlsx.mdx index bda4aed..23f5311 100644 --- a/website/docs/commands/export/export to_xlsx.mdx +++ b/website/docs/commands/export/export to_xlsx.mdx @@ -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', }, ] }> @@ -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"; @@ -421,7 +421,7 @@ module.exports = { }, worksheetName: "Settings 4 - Worksheet", filename: "settings4-output", - outputDir: "D:\\TEMP\\TEMP", + outputDir: "D:\\TEMP\\TEMP" }; ``` diff --git a/website/docs/commands/import/import from_csv.mdx b/website/docs/commands/import/import from_csv.mdx index 59e442a..0e9240b 100644 --- a/website/docs/commands/import/import from_csv.mdx +++ b/website/docs/commands/import/import from_csv.mdx @@ -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', }, ] }> @@ -202,4 +203,34 @@ npx @jy95/i18n-tools import from_csv --settings "/absolutePath/to/settings2.json + + +```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", +}; +``` + + \ No newline at end of file diff --git a/website/docs/commands/import/import from_xlsx.mdx b/website/docs/commands/import/import from_xlsx.mdx index b25ee40..edb3e59 100644 --- a/website/docs/commands/import/import from_xlsx.mdx +++ b/website/docs/commands/import/import from_xlsx.mdx @@ -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', }, ] }> @@ -190,4 +191,34 @@ npx @jy95/i18n-tools import from_xlsx --settings "/absolutePath/to/settings2.jso + + +```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", +}; +``` + + \ No newline at end of file