Skip to content

Commit 41ce2d7

Browse files
Add --useI18nRepoOnly=true
1 parent bd398b9 commit 41ce2d7

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

packages/@okta/verify-translations/verify-translations.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { resolve } = require('path');
22
const fs = require('fs');
33
const properties = require('properties');
44

5-
const { CI, I18N_REPO_PATH, WRITE_FIXED_I18N } = process.env;
5+
const { CI, I18N_REPO_PATH, WRITE_FIXED_I18N, USE_I18N_REPO_ONLY } = process.env;
66
const ROOT_DIR = resolve(__dirname, '../../../');
77
const OKTA_I18N_PROPERTIES = `${ROOT_DIR}/packages/@okta/i18n/src/properties`;
88
const I18N_REPO = I18N_REPO_PATH ? I18N_REPO_PATH : resolve(ROOT_DIR, '../i18n');
@@ -64,6 +64,13 @@ const getCoreResourcesPath = () => {
6464
throw new Error(`No i18n repo found at ${I18N_REPO}`);
6565
};
6666

67+
const getSiwResourcesPath = () => {
68+
if (USE_I18N_REPO_ONLY === 'true') {
69+
return `${I18N_REPO}/packages/login`;
70+
}
71+
return OKTA_I18N_PROPERTIES;
72+
};
73+
6774
const getLanguges = ({ resourcePath, bundle }) => {
6875
const fileNames = fs.readdirSync(resourcePath).filter(fileName =>
6976
fileName.startsWith(bundle) && fileName.endsWith('.properties')
@@ -124,9 +131,11 @@ const buildCompexityKeysMapping = (siwTranslations, coreTranslations) => {
124131
const verifyTranslations = async ({ canUpdate }) => {
125132
let res = 0;
126133
const coreResourcesPath = getCoreResourcesPath();
127-
console.log(`Using resource path: ${coreResourcesPath}`);
134+
const siwResourcesPath = getSiwResourcesPath();
135+
console.log(`Using core resource path: ${coreResourcesPath}`);
136+
console.log(`Using widget resource path: ${siwResourcesPath}`);
128137
const siwLangs = getLanguges({
129-
resourcePath: OKTA_I18N_PROPERTIES,
138+
resourcePath: siwResourcesPath,
130139
bundle: 'login',
131140
});
132141
const coreLangs = getLanguges({
@@ -135,7 +144,7 @@ const verifyTranslations = async ({ canUpdate }) => {
135144
});
136145
for (let siwLang of siwLangs) {
137146
const siwProperties = await parseProperties({
138-
resourcePath: OKTA_I18N_PROPERTIES,
147+
resourcePath: siwResourcesPath,
139148
bundle: 'login',
140149
lang: siwLang,
141150
});
@@ -173,7 +182,7 @@ const verifyTranslations = async ({ canUpdate }) => {
173182
console.log(updates);
174183
if (canUpdate) {
175184
updateProperties({
176-
resourcePath: OKTA_I18N_PROPERTIES,
185+
resourcePath: siwResourcesPath,
177186
bundle: 'login',
178187
lang: siwLang,
179188
updates,
@@ -194,7 +203,7 @@ const verifyTranslations = async ({ canUpdate }) => {
194203

195204
const start = async () => {
196205
const res = await verifyTranslations({
197-
canUpdate: !CI && WRITE_FIXED_I18N === 'true'
206+
canUpdate: !CI && WRITE_FIXED_I18N === 'true' && USE_I18N_REPO_ONLY !== 'true'
198207
});
199208
process.exit(res);
200209
};

scripts/buildtools/commands/verify-translations.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ exports.builder = {
1414
type: 'boolean',
1515
default: false,
1616
},
17+
useI18nRepoOnly: {
18+
description: 'True to compare core and SIW translations in i18n repo only, ignoring translations in SIW repo',
19+
type: 'boolean',
20+
default: false,
21+
}
1722
};
1823

1924
exports.handler = async (argv) => {
@@ -31,6 +36,9 @@ exports.handler = async (argv) => {
3136
if (argv.i18nRepoPath) {
3237
verifyCmd = `I18N_REPO_PATH="${argv.i18nRepoPath}" ${verifyCmd}`;
3338
}
39+
if (argv.useI18nRepoOnly) {
40+
verifyCmd = `USE_I18N_REPO_ONLY=true ${verifyCmd}`;
41+
}
3442
if (argv.write) {
3543
verifyCmd = `WRITE_FIXED_I18N=true ${verifyCmd}`;
3644
}

0 commit comments

Comments
 (0)