@@ -5,7 +5,7 @@ const path = require('path')
55
66// expected to follow the pattern baseName_language[_script]_country_variant.properties
77// source: https://docs.oracle.com/javase/9/docs/api/java/util/ResourceBundle.html#getBundle-java.lang.String-java.util.Locale-java.lang.ClassLoader-
8- function localeFromResourcePath ( resourcePath , pathSep , defaultLocale ) {
8+ function localeFromResourcePath ( resourcePath , pathSep , defaultLocale ) {
99 const parts = path . basename ( resourcePath ) . split ( pathSep )
1010 const locale = parts [ 1 ] && parts [ 1 ] . replace ( / \. .* $ / , '' ) . toLowerCase ( )
1111 if ( locale === 'pt-pt' || ( locale === 'pt' && / ^ p t / i. test ( parts [ 2 ] ) ) ) {
@@ -15,11 +15,16 @@ function localeFromResourcePath (resourcePath, pathSep, defaultLocale) {
1515 return / ^ [ a - z ] { 2 , 3 } $ / . test ( locale || '' ) ? locale : defaultLocale
1616}
1717
18- module . exports = function ( content ) {
19- const { biDiSupport, defaultLocale, encoding, keyPath, pathSep } = loaderUtils . getOptions ( this ) || { }
18+ module . exports = function ( content ) {
19+ const { biDiSupport, defaultLocale, encoding, keyPath, pathSep } =
20+ loaderUtils . getOptions ( this ) || { }
2021 const input = content . toString ( encoding || 'latin1' )
2122 const translations = parse ( input , keyPath || false )
22- const locale = localeFromResourcePath ( this . resourcePath , pathSep || '_' , defaultLocale || 'en' )
23+ const locale = localeFromResourcePath (
24+ this . resourcePath ,
25+ pathSep || '_' ,
26+ defaultLocale || 'en'
27+ )
2328 const mf = new MessageFormat ( locale )
2429 if ( biDiSupport ) mf . setBiDiSupport ( )
2530 return mf . compile ( translations ) . toString ( 'module.exports' )
0 commit comments