@@ -19,7 +19,7 @@ describe('y18n', function () {
1919 describe ( '_readLocaleFile' , function ( ) {
2020 it ( 'throws a helpful error if language file has invalid syntax' , function ( ) {
2121 expect ( function ( ) {
22- var __ = y18n ( {
22+ const __ = y18n ( {
2323 locale : 'bad-locale' ,
2424 directory : path . join ( __dirname , 'locales' )
2525 } ) . __
@@ -31,30 +31,30 @@ describe('y18n', function () {
3131
3232 describe ( '__' , function ( ) {
3333 it ( 'can be used as a tag for template literals' , function ( ) {
34- var __ = y18n ( {
34+ const __ = y18n ( {
3535 locale : 'pirate' ,
3636 directory : path . join ( __dirname , 'locales' )
3737 } ) . __
3838
3939 __ `Hi, ${ 'Ben' } ${ 'Coe' } !` . should . equal ( 'Yarr! Shiver me timbers, why \'tis Ben Coe!' )
4040 } )
4141 it ( 'can be used as a tag for template literals with falsy arguments' , function ( ) {
42- var __ = y18n ( {
42+ const __ = y18n ( {
4343 locale : 'pirate' ,
4444 directory : path . join ( __dirname , 'locales' )
4545 } ) . __
4646 __ `Hi, ${ 'Ben' } ${ '' } !` . should . equal ( 'Yarr! Shiver me timbers, why \'tis Ben !' )
4747 } )
4848 it ( 'uses replacements from the default locale if none is configured' , function ( ) {
49- var __ = y18n ( {
49+ const __ = y18n ( {
5050 directory : path . join ( __dirname , 'locales' )
5151 } ) . __
5252
5353 __ ( 'Hello' ) . should . equal ( 'Hello!' )
5454 } )
5555
5656 it ( 'uses replacements from the configured locale' , function ( ) {
57- var __ = y18n ( {
57+ const __ = y18n ( {
5858 locale : 'pirate' ,
5959 directory : path . join ( __dirname , 'locales' )
6060 } ) . __
@@ -63,7 +63,7 @@ describe('y18n', function () {
6363 } )
6464
6565 it ( 'uses language file if language_territory file does not exist' , function ( ) {
66- var __ = y18n ( {
66+ const __ = y18n ( {
6767 locale : 'pirate_JM' ,
6868 directory : path . join ( __dirname , 'locales' )
6969 } ) . __
@@ -72,7 +72,7 @@ describe('y18n', function () {
7272 } )
7373
7474 it ( 'does not fallback to language file if fallbackToLanguage is false' , function ( ) {
75- var __ = y18n ( {
75+ const __ = y18n ( {
7676 locale : 'pirate_JM' ,
7777 fallbackToLanguage : false ,
7878 updateFiles : false ,
@@ -83,7 +83,7 @@ describe('y18n', function () {
8383 } )
8484
8585 it ( 'uses strings as given if no matching locale files found' , function ( ) {
86- var __ = y18n ( {
86+ const __ = y18n ( {
8787 locale : 'zz_ZZ' ,
8888 updateFiles : false ,
8989 directory : path . join ( __dirname , 'locales' )
@@ -93,7 +93,7 @@ describe('y18n', function () {
9393 } )
9494
9595 it ( 'expands arguments into %s placeholders' , function ( ) {
96- var __ = y18n ( {
96+ const __ = y18n ( {
9797 directory : path . join ( __dirname , 'locales' )
9898 } ) . __
9999
@@ -108,7 +108,7 @@ describe('y18n', function () {
108108 } )
109109
110110 it ( 'returns the word immediately' , function ( ) {
111- var __ = y18n ( {
111+ const __ = y18n ( {
112112 locale : 'fr' ,
113113 directory : path . join ( __dirname , 'locales' )
114114 } ) . __
@@ -117,13 +117,13 @@ describe('y18n', function () {
117117 } )
118118
119119 it ( 'writes new word to locale file if updateFiles is true' , function ( done ) {
120- var __ = y18n ( {
120+ const __ = y18n ( {
121121 locale : 'fr_FR' ,
122122 directory : path . join ( __dirname , 'locales' )
123123 } ) . __
124124
125125 __ ( 'banana' , function ( err ) {
126- var locale = JSON . parse ( fs . readFileSync ( './test/locales/fr_FR.json' , 'utf-8' ) )
126+ const locale = JSON . parse ( fs . readFileSync ( './test/locales/fr_FR.json' , 'utf-8' ) )
127127 locale . banana . should . equal ( 'banana' )
128128 return done ( err )
129129 } )
@@ -132,14 +132,14 @@ describe('y18n', function () {
132132 it ( 'writes new word to language file if language_territory file does not exist' , function ( done ) {
133133 fs . writeFileSync ( './test/locales/fr.json' , '{"meow": "le meow"}' , 'utf-8' )
134134
135- var __ = y18n ( {
135+ const __ = y18n ( {
136136 locale : 'fr_FR' ,
137137 directory : path . join ( __dirname , 'locales' )
138138 } ) . __
139139
140140 __ ( 'meow' ) . should . equal ( 'le meow' )
141141 __ ( 'banana' , function ( err ) {
142- var locale = JSON . parse ( fs . readFileSync ( './test/locales/fr.json' , 'utf-8' ) )
142+ const locale = JSON . parse ( fs . readFileSync ( './test/locales/fr.json' , 'utf-8' ) )
143143 locale . banana . should . equal ( 'banana' )
144144 return done ( err )
145145 } )
@@ -148,20 +148,20 @@ describe('y18n', function () {
148148 it ( 'writes word to missing locale file, if no fallback takes place' , function ( done ) {
149149 fs . writeFileSync ( './test/locales/fr.json' , '{"meow": "le meow"}' , 'utf-8' )
150150
151- var __ = y18n ( {
151+ const __ = y18n ( {
152152 locale : 'fr_FR' ,
153153 fallbackToLanguage : false ,
154154 directory : path . join ( __dirname , 'locales' )
155155 } ) . __
156156
157157 __ ( 'banana' , function ( err ) {
158158 // 'banana' should be written to fr_FR.json
159- var locale = JSON . parse ( fs . readFileSync ( './test/locales/fr_FR.json' , 'utf-8' ) )
159+ const locale = JSON . parse ( fs . readFileSync ( './test/locales/fr_FR.json' , 'utf-8' ) )
160160 locale . should . deep . equal ( {
161161 banana : 'banana'
162162 } )
163163 // fr.json should remain untouched
164- var frJson = JSON . parse ( fs . readFileSync ( './test/locales/fr.json' , 'utf-8' ) )
164+ const frJson = JSON . parse ( fs . readFileSync ( './test/locales/fr.json' , 'utf-8' ) )
165165 frJson . should . deep . equal ( {
166166 meow : 'le meow'
167167 } )
@@ -170,7 +170,7 @@ describe('y18n', function () {
170170 } )
171171
172172 it ( 'handles enqueuing multiple writes at the same time' , function ( done ) {
173- var __ = y18n ( {
173+ const __ = y18n ( {
174174 locale : 'fr' ,
175175 directory : path . join ( __dirname , 'locales' )
176176 } ) . __
@@ -179,7 +179,7 @@ describe('y18n', function () {
179179 __ ( 'banana' , function ( ) {
180180 __ ( 'foo' )
181181 __ ( 'bar' , function ( err ) {
182- var locale = JSON . parse ( fs . readFileSync ( './test/locales/fr.json' , 'utf-8' ) )
182+ const locale = JSON . parse ( fs . readFileSync ( './test/locales/fr.json' , 'utf-8' ) )
183183 locale . apple . should . equal ( 'apple' )
184184 locale . banana . should . equal ( 'banana' )
185185 locale . foo . should . equal ( 'foo' )
@@ -190,7 +190,7 @@ describe('y18n', function () {
190190 } )
191191
192192 it ( 'does not write the locale file if updateFiles is false' , function ( done ) {
193- var __ = y18n ( {
193+ const __ = y18n ( {
194194 locale : 'fr' ,
195195 updateFiles : false ,
196196 directory : path . join ( __dirname , 'locales' )
@@ -206,31 +206,31 @@ describe('y18n', function () {
206206
207207 describe ( '__n' , function ( ) {
208208 it ( 'uses the singular form if quantity is 1' , function ( ) {
209- var __n = y18n ( {
209+ const __n = y18n ( {
210210 directory : path . join ( __dirname , 'locales' )
211211 } ) . __n
212212
213213 __n ( '%d cat' , '%d cats' , 1 ) . should . equal ( '1 cat' )
214214 } )
215215
216216 it ( 'uses the plural form if quantity is greater than 1' , function ( ) {
217- var __n = y18n ( {
217+ const __n = y18n ( {
218218 directory : path . join ( __dirname , 'locales' )
219219 } ) . __n
220220
221221 __n ( '%d cat' , '%d cats' , 2 ) . should . equal ( '2 cats' )
222222 } )
223223
224224 it ( 'allows additional arguments to be printed' , function ( ) {
225- var __n = y18n ( {
225+ const __n = y18n ( {
226226 directory : path . join ( __dirname , 'locales' )
227227 } ) . __n
228228
229229 __n ( '%d %s cat' , '%d %s cats' , 2 , 'black' ) . should . equal ( '2 black cats' )
230230 } )
231231
232232 it ( 'allows an alternative locale to be set' , function ( ) {
233- var __n = y18n ( {
233+ const __n = y18n ( {
234234 locale : 'pirate' ,
235235 directory : path . join ( __dirname , 'locales' )
236236 } ) . __n
@@ -241,12 +241,12 @@ describe('y18n', function () {
241241
242242 // See: https://github.com/bcoe/yargs/pull/210
243243 it ( 'allows a quantity placeholder to be provided in the plural but not singular form' , function ( ) {
244- var __n = y18n ( {
244+ const __n = y18n ( {
245245 directory : path . join ( __dirname , 'locales' )
246246 } ) . __n
247247
248- var singular = __n ( 'There is one monkey in the %s' , 'There are %d monkeys in the %s' , 1 , 'tree' )
249- var plural = __n ( 'There is one monkey in the %s' , 'There are %d monkeys in the %s' , 3 , 'tree' )
248+ const singular = __n ( 'There is one monkey in the %s' , 'There are %d monkeys in the %s' , 1 , 'tree' )
249+ const plural = __n ( 'There is one monkey in the %s' , 'There are %d monkeys in the %s' , 3 , 'tree' )
250250
251251 singular . should . equal ( 'There is one monkey in the tree' )
252252 plural . should . equal ( 'There are 3 monkeys in the tree' )
@@ -260,7 +260,7 @@ describe('y18n', function () {
260260 } )
261261
262262 it ( 'returns the pluralization immediately' , function ( ) {
263- var __n = y18n ( {
263+ const __n = y18n ( {
264264 locale : 'fr' ,
265265 directory : path . join ( __dirname , 'locales' )
266266 } ) . __n
@@ -269,21 +269,21 @@ describe('y18n', function () {
269269 } )
270270
271271 it ( 'writes to the locale file if updateFiles is true' , function ( done ) {
272- var __n = y18n ( {
272+ const __n = y18n ( {
273273 locale : 'fr' ,
274274 directory : path . join ( __dirname , 'locales' )
275275 } ) . __n
276276
277277 __n ( '%d apple %s' , '%d apples %s' , 2 , 'dude' , function ( err ) {
278- var locale = JSON . parse ( fs . readFileSync ( './test/locales/fr.json' , 'utf-8' ) )
278+ const locale = JSON . parse ( fs . readFileSync ( './test/locales/fr.json' , 'utf-8' ) )
279279 locale [ '%d apple %s' ] . one . should . equal ( '%d apple %s' )
280280 locale [ '%d apple %s' ] . other . should . equal ( '%d apples %s' )
281281 return done ( err )
282282 } )
283283 } )
284284
285285 it ( 'does not write the locale file if updateFiles is false' , function ( done ) {
286- var __n = y18n ( {
286+ const __n = y18n ( {
287287 locale : 'fr' ,
288288 updateFiles : false ,
289289 directory : path . join ( __dirname , 'locales' )
@@ -299,7 +299,7 @@ describe('y18n', function () {
299299
300300 describe ( 'setLocale' , function ( ) {
301301 it ( 'switches the locale' , function ( ) {
302- var i18n = y18n ( {
302+ const i18n = y18n ( {
303303 directory : path . join ( __dirname , 'locales' )
304304 } )
305305
@@ -317,7 +317,7 @@ describe('y18n', function () {
317317 } )
318318
319319 it ( 'updates the locale with the new lookups provided' , function ( ) {
320- var i18n = y18n ( {
320+ const i18n = y18n ( {
321321 locale : 'fr' ,
322322 directory : path . join ( __dirname , 'locales' )
323323 } )
@@ -332,7 +332,7 @@ describe('y18n', function () {
332332 it ( 'loads the locale from disk prior to updating the map' , function ( ) {
333333 fs . writeFileSync ( './test/locales/fr.json' , '{"meow": "le meow"}' , 'utf-8' )
334334
335- var i18n = y18n ( {
335+ const i18n = y18n ( {
336336 locale : 'fr' ,
337337 directory : path . join ( __dirname , 'locales' )
338338 } )
0 commit comments