@@ -6,28 +6,35 @@ const pathToCombinedTranslationKeys = path.join(
66 './translationKeys/combined-translation-keys.txt'
77) ;
88
9- const pathToArrowsOut = path . join (
10- __dirname ,
11- '../src/locales/xx.js'
12- ) ;
9+ const pathToArrowsOut = path . join ( __dirname , '../src/locales/xx.js' ) ;
1310
1411const wordRE = / ^ [ A - Z a - z ] + $ / ;
1512
1613function makeArrows ( ) {
17- const lines = fs . readFileSync ( pathToCombinedTranslationKeys , 'utf-8' ) . split ( / \r ? \n / ) ;
18- const entries = lines . map ( line => {
19- const key = line . split ( / \/ \/ / ) [ 0 ] . trim ( ) ;
20- const escapedKey = key . replace ( / \' / g, '\\\'' ) ;
21- const maybeQuoteKey = wordRE . test ( key ) ? key : '\'' + escapedKey + '\'' ;
22- const arrowStr = arrowPad ( getArrowLen ( key ) ) ;
23-
24- return ' ' + maybeQuoteKey + ': \'' + arrowStr + escapedKey + arrowStr + '\'' ;
25- } ) . join ( ',\n' ) ;
26-
14+ const lines = fs
15+ . readFileSync ( pathToCombinedTranslationKeys , 'utf-8' )
16+ . split ( / \r ? \n / ) ;
17+ const entries = lines
18+ . map ( line => {
19+ const key = line . split ( / \/ \/ / ) [ 0 ] . trim ( ) ;
20+ const escapedKey = key . replace ( / \' / g, "\\'" ) ;
21+ const maybeQuoteKey = wordRE . test ( key ) ? key : "'" + escapedKey + "'" ;
22+ const arrowStr = arrowPad ( getArrowLen ( key ) ) ;
23+
24+ return (
25+ ' ' + maybeQuoteKey + ": '" + arrowStr + escapedKey + arrowStr + "'"
26+ ) ;
27+ } )
28+ . join ( ',\n' ) ;
29+
30+ const ignorePrettier = '/* eslint-disable prettier */' ;
2731 const head = 'export default {' ;
2832 const tail = '}' ;
2933
30- fs . writeFile ( pathToArrowsOut , [ head , entries , tail ] . join ( '\n' ) )
34+ fs . writeFile (
35+ pathToArrowsOut ,
36+ [ ignorePrettier , head , entries , tail ] . join ( '\n' )
37+ ) ;
3138 console . log ( 'arrows mock translation written to: ' + pathToArrowsOut ) ;
3239}
3340
@@ -38,7 +45,7 @@ function getArrowLen(key) {
3845
3946function arrowPad ( n ) {
4047 let out = '' ;
41- for ( let i = 0 ; i < n ; i ++ ) {
48+ for ( let i = 0 ; i < n ; i ++ ) {
4249 out += '⇚' ;
4350 }
4451 return out ;
0 commit comments