Skip to content

Commit 3cfc94b

Browse files
feat(cli): add --locale flag (#83)
1 parent b94f9eb commit 3cfc94b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.changeset/modern-feet-happen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"replexica": minor
3+
---
4+
5+
add --locale flag to cli to run translations on specific locales only

packages/cli/src/i18n.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default new Command()
1313
.helpOption('-h, --help', 'Show help')
1414
.option('--cache-only', 'Only use cached data, and fail if there is new i18n data to process')
1515
.option('--skip-cache', 'Skip using cached data and process all i18n data')
16+
.option('--locale <locale>', 'Locale to process')
1617
.action(async (options) => {
1718
let spinner = Ora();
1819

@@ -28,11 +29,18 @@ export default new Command()
2829
});
2930
spinner.succeed(`Authenticated as ${auth.email}.`);
3031

31-
3232
const sourceLocale = config.locale.source;
33-
const targetLocales = config.locale.targets;
33+
let targetLocales = config.locale.targets;
3434
const bucketEntries = Object.entries(config.buckets!);
3535

36+
if (flags.locale) {
37+
if (!targetLocales.includes(flags.locale as any)) {
38+
spinner.warn(`Target locale ${flags.locale} not found in configuration. Skipping...`);
39+
targetLocales = [];
40+
} else {
41+
targetLocales = [flags.locale as any];
42+
}
43+
}
3644
if (!targetLocales.length) {
3745
spinner.warn('No target locales found in configuration. Please add at least one target locale.');
3846
} else if (!bucketEntries.length) {
@@ -75,6 +83,7 @@ async function loadFlags(options: any) {
7583
const flags = Z.object({
7684
cacheOnly: Z.boolean().optional().default(false),
7785
skipCache: Z.boolean().optional().default(false),
86+
locale: Z.string().optional(),
7887
})
7988
.passthrough()
8089
.parse(options);

0 commit comments

Comments
 (0)