@@ -9,32 +9,40 @@ exports.hasCalendars = hasCalendars;
9
9
exports . hasNumbersFields = hasNumbersFields ;
10
10
exports . normalizeLocale = normalizeLocale ;
11
11
12
+ var CLDR_DATES_DIR = path . dirname ( require . resolve ( 'cldr-dates-full/package.json' ) ) ;
13
+ var CLDR_NUMBERS_DIR = path . dirname ( require . resolve ( 'cldr-numbers-full/package.json' ) ) ;
14
+
12
15
// These are the exceptions to the default algorithm for determining a locale's
13
16
// parent locale.
14
- var PARENT_LOCALES_HASH = require ( '../../data /supplemental/parentLocales.json' )
17
+ var PARENT_LOCALES_HASH = require ( 'cldr-core /supplemental/parentLocales.json' )
15
18
. supplemental . parentLocales . parentLocale ;
16
19
17
20
var CALENDARS_LOCALES_HASH = glob . sync ( '*/ca-*.json' , {
18
- cwd : path . resolve ( __dirname , '../../data/ main' ) ,
21
+ cwd : path . resolve ( CLDR_DATES_DIR , 'main' ) ,
19
22
} ) . reduce ( function ( hash , filename ) {
20
23
hash [ path . dirname ( filename ) ] = true ;
21
24
return hash ;
22
25
} , { } ) ;
23
26
24
27
var NUMBERS_LOCALES_HASH = glob . sync ( '*/numbers.json' , {
25
- cwd : path . resolve ( __dirname , '../../data/ main' ) ,
28
+ cwd : path . resolve ( CLDR_NUMBERS_DIR , 'main' ) ,
26
29
} ) . reduce ( function ( hash , filename ) {
27
30
hash [ path . dirname ( filename ) ] = true ;
28
31
return hash ;
29
32
} , { } ) ;
30
33
31
34
var CURRENCIES_LOCALES_HASH = glob . sync ( '*/currencies.json' , {
32
- cwd : path . resolve ( __dirname , '../../data/ main' ) ,
35
+ cwd : path . resolve ( CLDR_NUMBERS_DIR , 'main' ) ,
33
36
} ) . reduce ( function ( hash , filename ) {
34
37
hash [ path . dirname ( filename ) ] = true ;
35
38
return hash ;
36
39
} , { } ) ;
37
40
41
+ var DEFAULT_CONTENT_ARRAY = require ( 'cldr-core/defaultContent.json' )
42
+ . defaultContent . map ( function ( value ) {
43
+ return value . replace ( / _ / g, '-' ) ;
44
+ } ) ;
45
+
38
46
// Some locales that have a `pluralRuleFunction` don't have a `dateFields.json`
39
47
// file, and visa versa, so this creates a unique collection of all locales in
40
48
// the CLDR for which we need data from.
@@ -43,6 +51,7 @@ var ALL_LOCALES_HASH =
43
51
. concat ( Object . keys ( CALENDARS_LOCALES_HASH ) )
44
52
. concat ( Object . keys ( NUMBERS_LOCALES_HASH ) )
45
53
. concat ( Object . keys ( CURRENCIES_LOCALES_HASH ) )
54
+ . concat ( DEFAULT_CONTENT_ARRAY )
46
55
. sort ( )
47
56
. reduce ( function ( hash , locale ) {
48
57
hash [ locale . toLowerCase ( ) ] = locale ;
0 commit comments