@@ -7,7 +7,10 @@ class LocalizedModel{
77 const model = this ;
88 this . _localizedProxy = new Proxy ( this , {
99 set ( target , prop , newVal ) {
10- const attrMap = model . _strMap [ prop ] ;
10+ var attrMap = model . _strMap [ prop ] ;
11+ if ( ! attrMap && prop !== '_strMap' && prop !== '_localeKey' && prop !== '_localizedProxy' ) {
12+ attrMap = model . _strMap [ prop ] = { } ;
13+ }
1114 if ( attrMap ) {
1215 model . _setLocalizedValue ( prop , newVal ) ;
1316 }
@@ -97,7 +100,10 @@ class LocalizedModel{
97100 return new Proxy ( object , {
98101 set ( target , prop , newVal ) {
99102 const resolvedAttrKey = `${ attrKey } .${ prop } ` ;
100- const attrMap = model . _strMap [ resolvedAttrKey ] ;
103+ var attrMap = model . _strMap [ resolvedAttrKey ] ;
104+ if ( ! attrMap && prop !== '_strMap' && prop !== '_localeKey' && prop !== '_localizedProxy' ) {
105+ attrMap = model . _strMap [ resolvedAttrKey ] = { } ;
106+ }
101107 if ( attrMap ) {
102108 model . _setLocalizedValue ( resolvedAttrKey , newVal ) ;
103109 }
@@ -153,6 +159,7 @@ class LocalizedModel{
153159 */
154160 inflateLocales ( attrKeyMap , arrIndex ) {
155161 var localeObj = { } ;
162+ var localeKeysMap = { } ;
156163
157164 Object . keys ( attrKeyMap ) . forEach ( ( cacheKey ) => {
158165 var resolvedCacheKey = cacheKey ;
@@ -162,6 +169,7 @@ class LocalizedModel{
162169 let attrMap = this . _strMap [ resolvedCacheKey ] ;
163170 if ( attrMap ) {
164171 Object . keys ( attrMap ) . forEach ( function ( localeKey ) {
172+ localeKeysMap [ localeKey ] = true ;
165173 const outputKey = attrKeyMap [ cacheKey ] ;
166174 if ( ! Object . prototype . hasOwnProperty . call ( localeObj , localeKey ) ) {
167175 localeObj [ localeKey ] = { } ;
@@ -171,6 +179,17 @@ class LocalizedModel{
171179 }
172180 } )
173181
182+ Object . keys ( localeKeysMap ) . forEach ( function ( localeKey ) {
183+ let localeMap = localeObj [ localeKey ]
184+
185+ Object . keys ( attrKeyMap ) . forEach ( ( cacheKey ) => {
186+ const outputKey = attrKeyMap [ cacheKey ] ;
187+ if ( ! Object . prototype . hasOwnProperty . call ( localeMap , outputKey ) ) {
188+ localeMap [ outputKey ] = '' ;
189+ }
190+ } )
191+ } )
192+
174193 return localeObj ;
175194 }
176195}
0 commit comments