File tree Expand file tree Collapse file tree 6 files changed +30
-13
lines changed Expand file tree Collapse file tree 6 files changed +30
-13
lines changed Original file line number Diff line number Diff line change 153153▸ ** postMessage** (` value ` : string): * [ DecimalSetting] ( _pages_decimal_setting_d_.decimalsetting.md ) *
154154
155155A string to be shown after the text input field. One common use for this field is to
156- specify a unit of measure.
156+ specify a unit of measure. Omitting the value and calling ` postMessage() ` will set the
157+ value to the default i18n string, allowing translations to be defines in the locale
158+ file in the usual way.
157159
158160** Parameters:**
159161
Original file line number Diff line number Diff line change 161161▸ ** postMessage** (` value ` : string): * [ NumberSetting] ( _pages_number_setting_d_.numbersetting.md ) *
162162
163163A string to be shown after the text input field. One common use for this field is to
164- specify a unit of measure.
164+ specify a unit of measure. Omitting the value and calling ` postMessage() ` will set the
165+ value to the default i18n string, allowing translations to be defines in the locale
166+ file in the usual way.
165167
166168** Parameters:**
167169
195197
196198▸ ** step** (` value ` : number): * [ NumberSetting] ( _pages_number_setting_d_.numbersetting.md ) *
197199
198- The step between values values . If the style is not set to slider then setting a step will
200+ The step between values. If the style is not set to slider then setting a step will
199201cause up and down arrows to appear next to the input box that increment or decrement the value
200202by the value of the step.
201203
Original file line number Diff line number Diff line change @@ -32,8 +32,10 @@ export class DecimalSetting extends SectionSetting<DecimalSetting> {
3232
3333 /**
3434 * A string to be shown after the text input field. One common use for this field is to
35- * specify a unit of measure.
35+ * specify a unit of measure. Omitting the value and calling `postMessage()` will set the
36+ * value to the default i18n string, allowing translations to be defines in the locale
37+ * file in the usual way.
3638 * @param value Max length 10 characters
3739 */
38- postMessage ( value : string ) : DecimalSetting
40+ postMessage ( value ? : string ) : DecimalSetting
3941}
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ module.exports = class DecimalSetting extends SectionSetting {
77 super ( section , id )
88 this . _type = 'DECIMAL'
99 this . _description = 'Tap to set'
10- this . _postMessage = this . i18nKey ( 'postMessage' )
1110 }
1211
1312 max ( value ) {
@@ -26,7 +25,12 @@ module.exports = class DecimalSetting extends SectionSetting {
2625 }
2726
2827 postMessage ( value ) {
29- this . _postMessage = value
28+ if ( value === undefined ) {
29+ this . _postMessage = this . i18nKey ( 'postMessage' )
30+ } else {
31+ this . _postMessage = value
32+ }
33+
3034 return this
3135 }
3236
@@ -45,7 +49,7 @@ module.exports = class DecimalSetting extends SectionSetting {
4549 }
4650
4751 if ( this . _postMessage ) {
48- result . postMessage = this . _postMessage
52+ result . postMessage = this . translate ( this . _postMessage )
4953 }
5054
5155 return result
Original file line number Diff line number Diff line change @@ -42,13 +42,15 @@ export class NumberSetting extends SectionSetting<NumberSetting> {
4242
4343 /**
4444 * A string to be shown after the text input field. One common use for this field is to
45- * specify a unit of measure.
45+ * specify a unit of measure. Omitting the value and calling `postMessage()` will set the
46+ * value to the default i18n string, allowing translations to be defines in the locale
47+ * file in the usual way.
4648 * @param value Max length 10 characters
4749 */
48- postMessage ( value : string ) : NumberSetting
50+ postMessage ( value ? : string ) : NumberSetting
4951
5052 /**
51- * The step between values values . If the style is not set to slider then setting a step will
53+ * The step between values. If the style is not set to slider then setting a step will
5254 * cause up and down arrows to appear next to the input box that increment or decrement the value
5355 * by the value of the step.
5456 */
Original file line number Diff line number Diff line change @@ -73,7 +73,12 @@ module.exports = class NumberSetting extends SectionSetting {
7373 * @returns {NumberSetting } Number Setting instance
7474 */
7575 postMessage ( value ) {
76- this . _postMessage = value
76+ if ( value === undefined ) {
77+ this . _postMessage = this . i18nKey ( 'postMessage' )
78+ } else {
79+ this . _postMessage = value
80+ }
81+
7782 return this
7883 }
7984
@@ -100,7 +105,7 @@ module.exports = class NumberSetting extends SectionSetting {
100105 }
101106
102107 if ( this . _postMessage ) {
103- result . postMessage = this . _postMessage
108+ result . postMessage = this . translate ( this . _postMessage )
104109 }
105110
106111 return result
You can’t perform that action at this time.
0 commit comments