Skip to content

Commit

Permalink
spaces option
Browse files Browse the repository at this point in the history
  • Loading branch information
while1618 committed Feb 22, 2024
1 parent 2e20850 commit aec93b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ $ i18n-auto-translation -k SUBSCRIPTION_KEY -d PROJECT_DIR -t DESIRED_LANGUAGE
| --to [required] | -t | To which language you want to translate. | / |
| --override | -o | Override all created i18n JSON files. | false |
| --certificatePath | -c | Path to a custom certificate. | / |
| --spaces | -s | Number of spaces to use when generating output JSON files. | 2 |

## Demo

Expand Down
7 changes: 7 additions & 0 deletions src/translate/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface Arguments {
to: string;
override: boolean;
certificatePath?: string;
spaces: number;
}

export const argv: Arguments = yargs(process.argv.slice(2))
Expand Down Expand Up @@ -78,5 +79,11 @@ export const argv: Arguments = yargs(process.argv.slice(2))
alias: 'c',
description: 'Path to a custom certificate.',
},
spaces: {
type: 'number',
alias: 's',
description: 'Number of spaces to use when generating output JSON files.',
default: 2,
},
})
.parseSync();
2 changes: 1 addition & 1 deletion src/translate/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export abstract class Translate {

private writeToFile = (content: JSONObj, saveTo: string, message: string): void => {
try {
fs.writeFileSync(saveTo, JSON.stringify(content, null, 2));
fs.writeFileSync(saveTo, JSON.stringify(content, null, argv.spaces));
console.log(message);
} catch (e) {
console.log((e as Error).message);
Expand Down

0 comments on commit aec93b2

Please sign in to comment.