File tree Expand file tree Collapse file tree 2 files changed +19
-15
lines changed Expand file tree Collapse file tree 2 files changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -160,19 +160,9 @@ export const promise = async ({
160
160
if ( fallbackLocale && fallbackLocale !== locale ) {
161
161
let fallbackValue
162
162
const isNullOrUndefined = typeof value === 'undefined' || value === null
163
- const fallbackIsArray =
164
- Array . isArray ( fallbackLocale ) ||
165
- ( fallbackLocale . startsWith ( '[' ) && fallbackLocale . endsWith ( ']' ) )
166
-
167
- if ( fallbackIsArray ) {
168
- const formattedFallback = Array . isArray ( fallbackLocale )
169
- ? fallbackLocale
170
- : fallbackLocale
171
- . slice ( 1 , - 1 )
172
- . split ( ',' )
173
- . map ( ( l ) => l . trim ( ) )
174
-
175
- for ( const locale of formattedFallback ) {
163
+
164
+ if ( Array . isArray ( fallbackLocale ) ) {
165
+ for ( const locale of fallbackLocale ) {
176
166
const val = siblingDoc [ field . name ! ] ?. [ locale ]
177
167
178
168
if ( val !== undefined && val !== null && val !== '' ) {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import type { SanitizedLocalizationConfig } from '../config/types.js'
2
2
import type { TypedLocale } from '../index.js'
3
3
4
4
interface Args {
5
- fallbackLocale : false | TypedLocale
5
+ fallbackLocale : false | TypedLocale | TypedLocale [ ]
6
6
locale : string
7
7
localization : SanitizedLocalizationConfig
8
8
}
@@ -26,7 +26,10 @@ export const sanitizeFallbackLocale = ({
26
26
hasFallbackLocale = Boolean ( localization && localization . fallback )
27
27
}
28
28
29
- if ( fallbackLocale && ! [ 'false' , 'none' , 'null' ] . includes ( fallbackLocale ) ) {
29
+ if (
30
+ fallbackLocale &&
31
+ ! [ 'false' , 'none' , 'null' ] . includes ( ! Array . isArray ( fallbackLocale ) ? fallbackLocale : '' )
32
+ ) {
30
33
hasFallbackLocale = true
31
34
}
32
35
@@ -52,5 +55,16 @@ export const sanitizeFallbackLocale = ({
52
55
fallbackLocale = null
53
56
}
54
57
58
+ if (
59
+ typeof fallbackLocale === 'string' &&
60
+ fallbackLocale . startsWith ( '[' ) &&
61
+ fallbackLocale . endsWith ( ']' )
62
+ ) {
63
+ fallbackLocale = fallbackLocale
64
+ . slice ( 1 , - 1 )
65
+ . split ( ',' )
66
+ . map ( ( l ) => l . trim ( ) )
67
+ }
68
+
55
69
return fallbackLocale as null | string
56
70
}
You can’t perform that action at this time.
0 commit comments