@@ -25,8 +25,6 @@ const transformYaml = async (content, { filename }) => {
25
25
return `export default ${ JSON . stringify ( load ( content , { filename } ) ) } ` ;
26
26
}
27
27
28
- const languageFileRegex = / ^ [ [ a - z ] { 2 } ( - [ a - z A - Z ] { 2 } ) ? \. ( [ a - z ] + ) $ / ;
29
-
30
28
const stdTransformers = {
31
29
// order matters as it defines which extensions are tried first
32
30
// when looking for a matching file for a locale
@@ -45,6 +43,7 @@ const stdTransformers = {
45
43
function svelteIntlPrecompile ( localesRoot , prefixOrOptions ) {
46
44
const {
47
45
prefix = '$locales' ,
46
+ exclude,
48
47
transformers : customTransformers ,
49
48
} = typeof prefixOrOptions === 'string'
50
49
? { prefix : prefixOrOptions }
@@ -62,9 +61,9 @@ function svelteIntlPrecompile(localesRoot, prefixOrOptions) {
62
61
] ;
63
62
64
63
const availableLocales = [ ] ;
65
- const filesInLocalesFolder = await fs . readdir ( localesRoot )
66
- // Only files named after standard language codes (e.g `en.json` or `en-US.json`) are valid.s
67
- const languageFiles = filesInLocalesFolder . filter ( name => languageFileRegex . test ( name ) ) ;
64
+ const filesInLocalesFolder = await fs . readdir ( localesRoot ) ;
65
+ const excludeFn = typeof exclude === 'function' ? exclude : ( exclude instanceof RegExp ? ( s ) => exclude . test ( s ) : ( ) => false ) ;
66
+ const languageFiles = filesInLocalesFolder . filter ( name => ! excludeFn ( name ) ) ;
68
67
69
68
// add register calls for each found locale
70
69
for ( const file of languageFiles ) {
0 commit comments