@@ -2,7 +2,7 @@ const { resolve } = require('path');
22const fs = require ( 'fs' ) ;
33const 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 ;
66const ROOT_DIR = resolve ( __dirname , '../../../' ) ;
77const OKTA_I18N_PROPERTIES = `${ ROOT_DIR } /packages/@okta/i18n/src/properties` ;
88const 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+
6774const 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) => {
124131const 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
195204const 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} ;
0 commit comments