File tree 2 files changed +7
-3
lines changed
2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 2
2
* Calculates the next fallback locale for the given locale.
3
3
*
4
4
* @param {string } locale Locale string in Java format (underscores) or null
5
- * @returns {string|null } Next fallback Locale or null if there is no more fallback
5
+ * @returns {string } Next fallback Locale or "en" if no fallbacks found.
6
6
*/
7
7
const nextFallbackLocale = locale => {
8
8
if ( ! locale ) {
9
- return null ;
9
+ return "en" ;
10
10
}
11
11
12
12
if ( locale === "zh_HK" ) {
Original file line number Diff line number Diff line change @@ -12,11 +12,15 @@ const M_ISO639_NEW_TO_OLD = {
12
12
/**
13
13
* Normalizes the given locale in BCP-47 syntax.
14
14
* @param {string } locale locale to normalize
15
- * @returns {string } Normalized locale or undefined if the locale can't be normalized
15
+ * @returns {string } Normalized locale, " undefined" if the locale can't be normalized or "en" if no locale provided.
16
16
*/
17
17
const normalizeLocale = locale => {
18
18
let m ;
19
19
20
+ if ( ! locale ) {
21
+ return "en" ;
22
+ }
23
+
20
24
if ( typeof locale === "string" && ( m = localeRegEX . exec ( locale . replace ( / _ / g, "-" ) ) ) ) { /* eslint-disable-line */
21
25
let language = m [ 1 ] . toLowerCase ( ) ;
22
26
let region = m [ 3 ] ? m [ 3 ] . toUpperCase ( ) : undefined ;
You can’t perform that action at this time.
0 commit comments