File tree 2 files changed +11
-3
lines changed
packages/decap-cms-core/src
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -47,8 +47,10 @@ import {
47
47
getI18nBackup ,
48
48
formatI18nBackup ,
49
49
getI18nInfo ,
50
+ I18N_STRUCTURE ,
50
51
} from './lib/i18n' ;
51
52
53
+ import type { I18nInfo } from './lib/i18n' ;
52
54
import type AssetProxy from './valueObjects/AssetProxy' ;
53
55
import type {
54
56
CmsConfig ,
@@ -308,6 +310,13 @@ function collectionDepth(collection: Collection) {
308
310
return depth ;
309
311
}
310
312
313
+ function i18nRulestring ( ruleString : string , { defaultLocale, structure } : I18nInfo ) : string {
314
+ if ( structure === I18N_STRUCTURE . MULTIPLE_FOLDERS ) {
315
+ return `${ defaultLocale } \\/${ ruleString } ` ;
316
+ }
317
+ return `${ ruleString } \\.${ defaultLocale } \\..*` ;
318
+ }
319
+
311
320
function collectionRegex ( collection : Collection ) : RegExp | undefined {
312
321
let ruleString = '' ;
313
322
@@ -319,8 +328,7 @@ function collectionRegex(collection: Collection): RegExp | undefined {
319
328
}
320
329
321
330
if ( hasI18n ( collection ) ) {
322
- const { defaultLocale } = getI18nInfo ( collection ) as { defaultLocale : string } ;
323
- ruleString += `\\.${ defaultLocale } \\..*` ;
331
+ ruleString = i18nRulestring ( ruleString , getI18nInfo ( collection ) as I18nInfo ) ;
324
332
}
325
333
326
334
return ruleString ? new RegExp ( ruleString ) : undefined ;
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export function hasI18n(collection: Collection) {
24
24
return collection . has ( I18N ) ;
25
25
}
26
26
27
- type I18nInfo = {
27
+ export type I18nInfo = {
28
28
locales : string [ ] ;
29
29
defaultLocale : string ;
30
30
structure : I18N_STRUCTURE ;
You can’t perform that action at this time.
0 commit comments