File tree Expand file tree Collapse file tree
packages/decap-cms-core/src/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -221,6 +221,24 @@ export function formatI18nBackup(
221221 return i18n ;
222222}
223223
224+ function applyDefaultI18nValues (
225+ collection : Collection ,
226+ value : EntryValue ,
227+ defaultLocaleValue : EntryValue ,
228+ ) {
229+ if ( collection . get ( 'fields' ) === undefined ) {
230+ return ;
231+ }
232+ collection . get ( 'fields' ) . forEach ( field => {
233+ if ( field && field . get ( I18N ) === I18N_FIELD . DUPLICATE ) {
234+ const data = value . data [ field . get ( 'name' ) ] ;
235+ if ( ! data ) {
236+ value . data [ field . get ( 'name' ) ] = defaultLocaleValue . data [ field . get ( 'name' ) ] ;
237+ }
238+ }
239+ } ) ;
240+ }
241+
224242function mergeValues (
225243 collection : Collection ,
226244 structure : I18N_STRUCTURE ,
@@ -236,6 +254,9 @@ function mergeValues(
236254 . filter ( e => e . locale !== defaultEntry ! . locale )
237255 . reduce ( ( acc , { locale, value } ) => {
238256 const dataPath = getLocaleDataPath ( locale ) ;
257+ if ( defaultEntry ) {
258+ applyDefaultI18nValues ( collection , value , defaultEntry . value ) ;
259+ }
239260 return set ( acc , dataPath , value . data ) ;
240261 } , { } ) ;
241262
You can’t perform that action at this time.
0 commit comments