@@ -10,6 +10,12 @@ export function presetField(fieldID, field, allFields) {
1010 allFields = allFields || { } ;
1111 let _this = Object . assign ( { } , field ) ; // shallow copy
1212
13+ // This handles fields that are composed of a base key and an index, like 'source:1'
14+ let localizerFieldID = fieldID ;
15+ if ( field . baseKey && field . index ) {
16+ localizerFieldID = field . baseKey + '_multiple' ;
17+ }
18+
1319 _this . id = fieldID ;
1420
1521 // for use in classes, element ids, css selectors
@@ -21,14 +27,14 @@ export function presetField(fieldID, field, allFields) {
2127 return ! _this . geometry || geometries . every ( geom => _this . geometry . indexOf ( geom ) !== - 1 ) ;
2228 } ;
2329
24- _this . t = ( scope , options ) => t ( localizer . coalesceStringIds ( [ `custom_presets.fields.${ fieldID } .${ scope } ` ,
25- `_tagging.presets.fields.${ fieldID } .${ scope } ` ] ) , options ) ;
26- _this . t . html = ( scope , options ) => t . html ( localizer . coalesceStringIds ( [ `custom_presets.fields.${ fieldID } .${ scope } ` ,
27- `_tagging.presets.fields.${ fieldID } .${ scope } ` ] ) , options ) ;
28- _this . t . append = ( scope , options ) => t . append ( localizer . coalesceStringIds ( [ `custom_presets.fields.${ fieldID } .${ scope } ` ,
29- `_tagging.presets.fields.${ fieldID } .${ scope } ` ] ) , options ) ;
30- _this . hasTextForStringId = ( scope ) => localizer . hasTextForStringId ( `custom_presets.fields.${ fieldID } .${ scope } ` ) ||
31- localizer . hasTextForStringId ( `_tagging.presets.fields.${ fieldID } .${ scope } ` ) ;
30+ _this . t = ( scope , options ) => t ( localizer . coalesceStringIds ( [ `custom_presets.fields.${ localizerFieldID } .${ scope } ` ,
31+ `_tagging.presets.fields.${ localizerFieldID } .${ scope } ` ] ) , options ) ;
32+ _this . t . html = ( scope , options ) => t . html ( localizer . coalesceStringIds ( [ `custom_presets.fields.${ localizerFieldID } .${ scope } ` ,
33+ `_tagging.presets.fields.${ localizerFieldID } .${ scope } ` ] ) , options ) ;
34+ _this . t . append = ( scope , options ) => t . append ( localizer . coalesceStringIds ( [ `custom_presets.fields.${ localizerFieldID } .${ scope } ` ,
35+ `_tagging.presets.fields.${ localizerFieldID } .${ scope } ` ] ) , options ) ;
36+ _this . hasTextForStringId = ( scope ) => localizer . hasTextForStringId ( `custom_presets.fields.${ localizerFieldID } .${ scope } ` ) ||
37+ localizer . hasTextForStringId ( `_tagging.presets.fields.${ localizerFieldID } .${ scope } ` ) ;
3238
3339 _this . resolveReference = which => {
3440 const referenceRegex = / ^ \{ ( .* ) \} $ / ;
@@ -43,10 +49,10 @@ export function presetField(fieldID, field, allFields) {
4349 return _this ;
4450 } ;
4551
46- _this . title = ( ) => _this . overrideLabel || _this . resolveReference ( 'label' ) . t ( 'label' , { 'default' : fieldID } ) ;
52+ _this . title = ( ) => _this . overrideLabel || _this . resolveReference ( 'label' ) . t ( 'label' , { 'default' : fieldID , 'index' : field . index } ) ;
4753 _this . label = ( ) => _this . overrideLabel ?
4854 selection => selection . text ( _this . overrideLabel ) :
49- _this . resolveReference ( 'label' ) . t . append ( 'label' , { 'default' : fieldID } ) ;
55+ _this . resolveReference ( 'label' ) . t . append ( 'label' , { 'default' : fieldID , 'index' : field . index } ) ;
5056
5157 _this . placeholder = ( ) => _this . resolveReference ( 'placeholder' ) . t ( 'placeholder' , { 'default' : '' } ) ;
5258
0 commit comments