@@ -13,7 +13,7 @@ const urlTools = require('urltools');
1313
1414const commandLineOptions = require ( 'optimist' )
1515 . usage (
16- '$0 --i18n <pathToI18nFile> [--locales <localeId>[,<localeId>...]] [--defaultlocale <localeId>] --babeldir=<dirContainingTheBabelFilesToApply> --root <inputRootDirectory> <htmlFile>...'
16+ '$0 --i18n <pathToI18nFile> [--locales <localeId>[,<localeId>...]] [--defaultlocale <localeId>] --babeldir=<dirContainingTheBabelFilesToApply> --root <inputRootDirectory> <htmlFile>...' ,
1717 )
1818 . options ( 'defaultlocale' , {
1919 describe :
@@ -33,8 +33,8 @@ const localeIds =
3333 commandLineOptions . locales &&
3434 _ . flatten (
3535 _ . flatten ( [ commandLineOptions . locales ] ) . map ( ( localeId ) =>
36- localeId . split ( ',' )
37- )
36+ localeId . split ( ',' ) ,
37+ ) ,
3838 ) . map ( i18nTools . normalizeLocaleId ) ;
3939
4040const initialAssetUrls = commandLineOptions . _ . map ( urlTools . fsFilePathToFileUrl ) ;
@@ -44,13 +44,13 @@ let i18nUrl;
4444
4545if ( commandLineOptions . defaultlocale ) {
4646 defaultLocaleId = i18nTools . normalizeLocaleId (
47- commandLineOptions . defaultlocale
47+ commandLineOptions . defaultlocale ,
4848 ) ;
4949 if ( localeIds && localeIds . indexOf ( defaultLocaleId ) === - 1 ) {
5050 throw new Error (
5151 `The default locale id (${ defaultLocaleId } ) is not among the locales listed with the --locales switch (${ localeIds . join (
52- ', '
53- ) } )`
52+ ', ' ,
53+ ) } )`,
5454 ) ;
5555 }
5656} else if ( localeIds ) {
@@ -108,7 +108,7 @@ if (commandLineOptions.i18n) {
108108
109109 const occurrencesByKey = i18nTools . findOccurrences (
110110 assetGraph ,
111- assetGraph . findAssets ( { type : 'Html' , isInitial : true } )
111+ assetGraph . findAssets ( { type : 'Html' , isInitial : true } ) ,
112112 ) ;
113113
114114 let i18nAssetForAllKeys ;
@@ -124,7 +124,7 @@ if (commandLineOptions.i18n) {
124124 assetGraph . addAsset ( i18nAssetForAllKeys ) ;
125125 assetGraph . emit (
126126 'info' ,
127- `--i18n ${ commandLineOptions . i18n } not found, creating it`
127+ `--i18n ${ commandLineOptions . i18n } not found, creating it` ,
128128 ) ;
129129 } else if ( ! i18nAssetForAllKeys . isLoaded ) {
130130 i18nAssetForAllKeys . parseTree = { } ;
@@ -143,14 +143,14 @@ if (commandLineOptions.i18n) {
143143
144144 const babelBody = fs . readFileSync (
145145 path . resolve ( commandLineOptions . babeldir , fileName ) ,
146- 'utf-8'
146+ 'utf-8' ,
147147 ) ;
148148
149149 isSeenByLocaleId [ localeId ] = true ;
150150
151151 if ( localeIds && localeIds . indexOf ( localeId ) === - 1 ) {
152152 console . warn (
153- `Skipping ${ fileName } because ${ localeId } was not mentioned in --locales`
153+ `Skipping ${ fileName } because ${ localeId } was not mentioned in --locales` ,
154154 ) ;
155155 return ;
156156 }
@@ -192,7 +192,7 @@ if (commandLineOptions.i18n) {
192192 throw new Error (
193193 `Error: Expected ${ JSON . stringify ( cursor ) } ['${
194194 path [ 0 ]
195- } '] to be undefined or an array while processing line ${ lineNumber } of ${ fileName } :\n${ line } `
195+ } '] to be undefined or an array while processing line ${ lineNumber } of ${ fileName } :\n${ line } `,
196196 ) ;
197197 }
198198 } else {
@@ -206,30 +206,30 @@ if (commandLineOptions.i18n) {
206206 throw new Error (
207207 `Error: Expected ${ JSON . stringify ( cursor ) } ['${
208208 path [ 0 ]
209- } '] to be undefined or an object while processing line ${ lineNumber } of ${ fileName } :\n${ line } `
209+ } '] to be undefined or an object while processing line ${ lineNumber } of ${ fileName } :\n${ line } `,
210210 ) ;
211211 }
212212 }
213213 cursor = cursor [ path . shift ( ) ] ;
214214 }
215215 if ( path [ 0 ] in cursor ) {
216216 throw new Error (
217- `Error: Found double declaration of key in line ${ lineNumber } of ${ fileName } :\n${ line } `
217+ `Error: Found double declaration of key in line ${ lineNumber } of ${ fileName } :\n${ line } ` ,
218218 ) ;
219219 }
220220 cursor [ path [ 0 ] ] = value ;
221221 } else {
222222 console . warn (
223223 `Couldn't parse line ${
224224 lineNumber + 1
225- } of the ${ localeId } file: ${ line } `
225+ } of the ${ localeId } file: ${ line } `,
226226 ) ;
227227 }
228228 }
229229 } ) ;
230230 } else {
231231 console . warn (
232- `Skipping file whose basename does not look like a locale id: ${ fileName } `
232+ `Skipping file whose basename does not look like a locale id: ${ fileName } ` ,
233233 ) ;
234234 }
235235 }
@@ -238,7 +238,7 @@ if (commandLineOptions.i18n) {
238238 localeIds . forEach ( ( localeId ) => {
239239 if ( ! isSeenByLocaleId [ localeId ] ) {
240240 console . warn (
241- `${ localeId } .txt was not found although --locales ${ localeId } was specified`
241+ `${ localeId } .txt was not found although --locales ${ localeId } was specified` ,
242242 ) ;
243243 }
244244 } ) ;
@@ -266,7 +266,7 @@ if (commandLineOptions.i18n) {
266266 keys . every (
267267 ( key ) =>
268268 [ 'zero' , 'one' , 'two' , 'few' , 'many' , 'other' ] . indexOf ( key ) !==
269- - 1
269+ - 1 ,
270270 )
271271 ) {
272272 keys = [ ] ;
@@ -279,7 +279,7 @@ if (commandLineOptions.i18n) {
279279 `${ key } : Discarding plural forms not used in ${ localeId } :` ,
280280 obj ,
281281 '=>' ,
282- coalescedObj
282+ coalescedObj ,
283283 ) ;
284284 }
285285 obj = coalescedObj ;
@@ -336,8 +336,8 @@ if (commandLineOptions.i18n) {
336336 _ . merge (
337337 Array . isArray ( newTranslation ) ? [ ] : { } ,
338338 existingTranslation ,
339- newTranslation
340- )
339+ newTranslation ,
340+ ) ,
341341 ) ;
342342 } else if (
343343 typeof existingTranslation === 'undefined' ||
@@ -404,7 +404,7 @@ if (commandLineOptions.i18n) {
404404 if (
405405 ! _ . isEqual (
406406 occurrence . defaultValue ,
407- allKeysInDefaultLocale [ occurrence . key ]
407+ allKeysInDefaultLocale [ occurrence . key ] ,
408408 )
409409 ) {
410410 if ( occurrence . type === 'TR' || occurrence . type === 'TRPAT' ) {
@@ -413,9 +413,9 @@ if (commandLineOptions.i18n) {
413413 const replaceRegExp = new RegExp (
414414 `(TR(?:PAT)?\\((['"])${ key . replace (
415415 / [ . [ \] * + ? { } ( ) ^ $ ] / g,
416- '\\$&'
416+ '\\$&' ,
417417 ) } \\2\\s*,\\s*)(?:[^)'"]*|"[^"]*"|'[^']*')*?\\)`,
418- 'g'
418+ 'g' ,
419419 ) ;
420420
421421 replacedTextByAssetId [ asset . id ] = (
@@ -425,8 +425,8 @@ if (commandLineOptions.i18n) {
425425 ) . replace (
426426 replaceRegExp ,
427427 `$1${ util . inspect (
428- translationsByKeyAndLocaleId [ key ] [ defaultLocaleId ]
429- ) } )`
428+ translationsByKeyAndLocaleId [ key ] [ defaultLocaleId ] ,
429+ ) } )`,
430430 ) ;
431431 }
432432 }
@@ -446,7 +446,7 @@ if (commandLineOptions.i18n) {
446446 $0
447447 . replace ( / & l t ; / g, '<' )
448448 . replace ( / & g t ; / g, '>' )
449- . replace ( / & a m p ; / g, '&' )
449+ . replace ( / & a m p ; / g, '&' ) ,
450450 ) ;
451451 }
452452 asset . _rawSrc = replacedText . toString ( 'utf-8' ) ;
0 commit comments