File tree 2 files changed +8
-4
lines changed
base/src/asset-registries
tools/lib/generate-json-imports
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,8 @@ const getI18nBundleData = packageName => {
28
28
* @public
29
29
*/
30
30
const registerI18nBundle = ( packageName , bundle ) => {
31
- bundleURLs . set ( packageName , bundle ) ;
31
+ const oldBundle = bundleURLs . get ( packageName ) || { } ;
32
+ bundleURLs . set ( packageName , Object . assign ( { } , oldBundle , bundle ) ) ;
32
33
} ;
33
34
34
35
/**
@@ -52,11 +53,11 @@ const fetchI18nBundle = async packageName => {
52
53
const language = getLocale ( ) . getLanguage ( ) ;
53
54
54
55
let localeId = normalizeLocale ( language ) ;
55
- while ( ! bundlesForPackage [ localeId ] ) {
56
+ while ( localeId !== DEFAULT_LANGUAGE && ! bundlesForPackage [ localeId ] ) {
56
57
localeId = nextFallbackLocale ( localeId ) ;
57
58
}
58
59
59
- if ( localeId === DEFAULT_LANGUAGE ) {
60
+ if ( ! bundlesForPackage [ localeId ] ) {
60
61
return ;
61
62
}
62
63
Original file line number Diff line number Diff line change 1
1
const fs = require ( "fs" ) ;
2
2
const path = require ( 'path' ) ;
3
3
const mkdirp = require ( "mkdirp" ) ;
4
+ const assets = require ( "../../assets-meta.js" ) ;
4
5
5
6
const packageName = JSON . parse ( fs . readFileSync ( "package.json" ) ) . name ;
6
7
7
8
const inputFolder = path . normalize ( process . argv [ 2 ] ) ;
8
9
const outputFile = path . normalize ( `${ process . argv [ 3 ] } /i18n.js` ) ;
9
10
11
+ const defaultLanguage = assets . languages . default ;
12
+
10
13
// All languages present in the file system
11
14
const files = fs . readdirSync ( inputFolder ) ;
12
15
const languages = files . map ( file => {
13
16
const matches = file . match ( / m e s s a g e b u n d l e _ ( .+ ?) .j s o n $ / ) ;
14
17
return matches ? matches [ 1 ] : undefined ;
15
- } ) . filter ( key => ! ! key ) ;
18
+ } ) . filter ( key => ! ! key && key !== defaultLanguage ) ;
16
19
17
20
let content ;
18
21
You can’t perform that action at this time.
0 commit comments