How to use the @iobroker/adapter-react/i18n.t function in @iobroker/adapter-react

To help you get started, we’ve selected a few @iobroker/adapter-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ioBroker / ioBroker.javascript / src / src / Editor.js View on Github external
// if anything except source was changed
                    if (JSON.stringify(commonLocal) !== JSON.stringify(this.objects[id].common)) {
                        this.scripts[id] = JSON.parse(JSON.stringify(this.objects[id].common));
                        this.scripts[id].source = oldSource;
                    }

                    if (oldSource !== this.objects[id].common.source) {
                        // take new script if it not yet changed
                        if (!this.state.changed[id]) {
                            // just use new value
                            this.scripts[id].source = this.objects[id].common.source;
                        } else {
                            if (this.objects[id].from && this.objects[id].from.startsWith('system.adapter.javascript.')) {
                                this.objects[id].from = 'system.adapter.admin.0';
                                // show that script was changed from outside
                                this.setState({toast: I18n.t('Script %s was modified on disk.', id.split('.').pop())});
                            }
                        }
                    } else {
                        if (this.state.changed[id]) {
                            newState.changed = newState.changed || JSON.parse(JSON.stringify(this.state.changed));
                            newState.changed[id] = false;
                            _changed = true;
                        }
                    }
                } else {
                    delete this.scripts[id];
                    if (this.state.selected === id) {
                        if (this.state.editing.indexOf(id) !== -1) {
                            const editing = JSON.parse(JSON.stringify(this.state.editing));
                            const pos = editing.indexOf(id);
                            if (pos !== -1) {
github ioBroker / ioBroker.javascript / src / src / Editor.js View on Github external
onConvert2JS() {
        this.showConfirmDialog(I18n.t('It will not be possible to revert this operation.'), result => {
            if (result) {
                this.scripts[this.state.selected].engineType = 'Javascript/js';
                let source = this.scripts[this.state.selected].source;
                const lines = source.split('\n');
                lines.pop();
                this.scripts[this.state.selected].source = lines.join('\n');
                const nowSelected = this.state.selected;

                const changed = JSON.parse(JSON.stringify(this.state.changed));
                changed[this.state.selected] = true;

                this.setState({changed, blockly: false, selected: ''}, () => {
                    this.setChangedInAdmin();
                    // force update of the editor
                    setTimeout(() => this.setState({selected: nowSelected}), 100);
                });
github ioBroker / ioBroker.javascript / src / src / Components / Schedule.js View on Github external
}
        else
        if (schedule.period.years) {
            if (schedule.period.years === 1) {
                desc.push(I18n.t('sch_desc_everyYear'));
            } else {
                desc.push(I18n.t('sch_desc_everyNYears', schedule.period.years));
            }
            desc.push(I18n.t('sch_desc_onDate', schedule.period.yearDate, schedule.period.yearMonth ? I18n.t(MONTHS[schedule.period.yearMonth - 1]) : I18n.t('sch_desc_everyMonth')));
        }

        // time
        if (schedule.time.exactTime) {
            if (ASTRO.indexOf(schedule.time.start) !== -1) {
                // at sunset
                desc.push(I18n.t('sch_desc_atTime', I18n.t('sch_astro_' + schedule.time.start)));
            } else {
                // at HH:MM
                desc.push(I18n.t('sch_desc_atTime', schedule.time.start));
            }
        } else {
            if (schedule.time.mode === PERIODS.minutes) {
                if (schedule.time.interval === 1) {
                    // every minute
                    desc.push(I18n.t('sch_desc_everyMinute'));
                } else {
                    // every N minutes
                    desc.push(I18n.t('sch_desc_everyNMinutes', schedule.time.interval));
                }
            } else {
                if (schedule.time.interval === 1) {
                    // every minute
github ioBroker / ioBroker.javascript / src / src / Components / simple-cron / SimpleCron.js View on Github external
getControlsPeriodElements(type) {
        const settings = this.state[type];

        if (this.state.extended) {
            return (<div style="{{paddingLeft:">
                <h5 style="{{marginBottom:">{I18n.t('sc_period')}</h5>
                 {
                        const settings = JSON.parse(JSON.stringify(this.state[type]));
                        settings.minutes = parseInt(e.target.value, 10);
                        if (settings.minutes &lt; 1) settings.minutes = 1;
                        this.setState({[type]: settings}, () =&gt; this.recalcCron());
                    }}
                    min={1}
                    max={60}
                    type="number"
                    InputLabelProps={{shrink: true,}}
                    margin="normal"
                /&gt;
                </div>
github ioBroker / ioBroker.javascript / src / src / App.js View on Github external
onImport(data) {
        this.importFile = data;
        if (data) {
            this.confirmCallback = this.onImportConfirmed.bind(this);
            this.setState({importFile: false, confirm: I18n.t('Existing scripts will be overwritten.')});
        } else {
            this.setState({importFile: false});
        }
    }
github ioBroker / ioBroker.javascript / src / src / Components / simple-cron / SimpleCron.js View on Github external
getControlsPeriodElements(type) {
        const settings = this.state[type];

        if (this.state.extended) {
            return (<div style="{{paddingLeft:">
                <h5 style="{{marginBottom:">{I18n.t('sc_period')}</h5>
                 {
                        const settings = JSON.parse(JSON.stringify(this.state[type]));
                        settings.minutes = parseInt(e.target.value, 10);
                        if (settings.minutes &lt; 1) settings.minutes = 1;
                        this.setState({[type]: settings}, () =&gt; this.recalcCron());
                    }}
                    min={1}
                    max={60}
                    type="number"
                    InputLabelProps={{shrink: true,}}
                    margin="normal"</div>
github ioBroker / ioBroker.iot / src / src / App.js View on Github external
render() {
        if (!this.state.loaded) {
            return ();
        }

        return (
            <div>
                
                     this.selectTab(e.target.parentNode.dataset.name, index)}&gt;
                        
                        
                        {this.state.native.amazonAlexa &amp;&amp; }
                        {this.state.native.googleHome &amp;&amp; }
                        {this.state.native.yandexAlisa &amp;&amp; }
                        
                        
                    
                

                <div>
                    {(this.state.selectedTab === 'options' || !this.state.selectedTab) &amp;&amp; ( this.setState({errorText: text})}
                        onLoad={native =&gt; this.onLoadConfig(native)}
                        instance={this.instance}
                        adapterName={this.adapterName}</div></div>
github ioBroker / ioBroker.javascript / src / src / Components / Schedule.js View on Github external
{
                                                                                                               const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
                                                                                                               const result = [];
                                                                                                               const parsedMonths = JSON.parse(_schedule.period.months);
                                                                                                               for (let i = 1; i &lt;= 12; i++) {
                                                                                                                   if (parsedMonths.indexOf(i) === -1) {
                                                                                                                       result.push(i);
                                                                                                                   }
                                                                                                               }
                                                                                                               result.sort((a, b) =&gt; a - b);
                                                                                                               _schedule.period.months = JSON.stringify(result);
                                                                                                               this.onChange(_schedule);
                                                                                                           }}
                                                                                                 /&gt;
                                                                                             } label={I18n.t('sch_invert')}
                    /&gt;)}
                    <div>
                    {MONTHS.map((month, i) =&gt; ( {
                                          const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
                                          let months;
                                          try {
                                              months = JSON.parse(_schedule.period.months);
                                          } catch (e) {
                                              months = [];
                                          }
                                          if (e.target.checked &amp;&amp; months.indexOf(i + 1) === -1) {
                                              months.push(i + 1);
                                          } else if (!e.target.checked &amp;&amp; months.indexOf(i + 1) !== -1) {</div>
github ioBroker / ioBroker.iot / src / src / Tabs / AlisaSmartNames.js View on Github external
style={{width: '100%'}}
                        label={I18n.t('Smart name')}
                        onKeyDown={e =&gt;
                            e.keyCode === 13 &amp;&amp; this.changeSmartName(e)}
                        onChange={e =&gt; this.editedSmartName = e.target.value}
                        defaultValue={this.state.editedSmartName}
                        helperText={I18n.t('You can enter several names divided by comma')}
                        margin="normal"
                    /&gt;
                
                
                    <button> this.changeSmartName()} color="primary" autoFocus&gt;{I18n.t('Ok')}</button>
                    <button> {
                        this.editedSmartName = null;
                        this.setState({editId: '', editedSmartName: ''});
                    }}&gt;{I18n.t('Cancel')}</button>
                
            )
        } else {
            return null;
        }
    }
github ioBroker / ioBroker.javascript / src / src / Components / Schedule.js View on Github external
}
                    this.onChange(_schedule);
                }}/&gt;)}
                label={I18n.t('sch_periodWeekend')} /&gt;),

            (<div style="{{verticalAlign:"> {
                    const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
                    _schedule.period.dows = '[0,1,2,3,4,5,6]';
                    if (_schedule.period.days) {
                        _schedule.period.days = 1;
                    }
                    this.onChange(_schedule);
                }}/&gt;)
                }
                label={I18n.t('sch_periodWeekdays')} /&gt;
                {isSpecific &amp;&amp; (schedule.period.days === 1 || schedule.period.weeks) &amp;&amp; (
                    {[1,2,3,4,5,6,0].map(i =&gt;
                        ( {
                                        const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
                                        let dows;
                                        try {
                                            dows = JSON.parse(_schedule.period.dows);
                                        } catch (e) {
                                            dows = [];
                                        }
                                        if (e.target.checked &amp;&amp; dows.indexOf(i) === -1) {
                                            dows.push(i);
                                        } else if (!e.target.checked &amp;&amp; dows.indexOf(i) !== -1) {
                                            dows.splice(dows.indexOf(i), 1);</div>