日期范围选择器的本地化

发布于 2025-01-05 23:22:23 字数 1806 浏览 1 评论 0原文

我对 javascript 和 jquery 很陌生。我一直在寻找解决这个问题的方法,但一无所获。我正在使用 http://www.filamentgroup.com/lab/date_range_picker_using_jquery_ui_16_and_jquery_ui_css_framework/

这是评论中建议的解决方案:

$("input").daterangepicker({
 dateFormat:"MM dd yyyy”,
 datepickerOptions: $j.extend({},
  $j.datepicker.regional[’de’], { //germany
  showStatus: true, //this is just a datepicker option
  showOn: “both”,//this is just a datepicker option
  changeYear :true//this is just a datepicker option
})
}); 

我尝试了上述方法,但无济于事。我对 javascript 很菜鸟,所以请耐心等待。

parent.$('#start_date_<?php echo $widget_id;?>').daterangepicker({
        monthOnly: true,
        arrows:false,
        dateFormat: 'MM yy',
        latestDate: '<?php echo date('Y-m-d');?>',
        presetRanges: [
            {text:'<?php echo lang('dashboards_month_to_date');?>', dateStart: 'm2d', dateEnd: 'today' },
            {text: '<?php echo lang('dashboards_quarter_to_date');?>', dateStart: 'q2d', dateEnd: 'today' },
            {text: '<?php echo lang('dashboards_year_to_date');?>', dateStart: 'y2d', dateEnd: 'today' }
        ],
        presets: {
            allDatesAfter: '<?php echo lang('dashboards_all_dates_from_first');?>'
        },
        altFields:'widgetDate_<?php echo $widget_id;?>',
        datepickerOptions: {
            changeMonth: true,
            changeYear: true,
            maxDate: Date.today()
        },
    });
    parent.$('#widgetDate_<?php echo $widget_id;?>S').val('<?php echo $options->widgetStartDate;?>');
},10);
{/eval}

假设我需要对法语进行本地化,有人可以给我分步指南来对上述代码进行本地化吗?任何帮助将不胜感激。

I'm very new to javascript and jquery. I've been searching up and down for a solution to this, but I'm getting nowhere. I'm using the daterangepicker from http://www.filamentgroup.com/lab/date_range_picker_using_jquery_ui_16_and_jquery_ui_css_framework/.

This was a suggested solution in the comments:

$("input").daterangepicker({
 dateFormat:"MM dd yyyy”,
 datepickerOptions: $j.extend({},
  $j.datepicker.regional[’de’], { //germany
  showStatus: true, //this is just a datepicker option
  showOn: “both”,//this is just a datepicker option
  changeYear :true//this is just a datepicker option
})
}); 

I tried the above approach, but go nowhere. I'm quite noob to javascript, so bear with me.

parent.$('#start_date_<?php echo $widget_id;?>').daterangepicker({
        monthOnly: true,
        arrows:false,
        dateFormat: 'MM yy',
        latestDate: '<?php echo date('Y-m-d');?>',
        presetRanges: [
            {text:'<?php echo lang('dashboards_month_to_date');?>', dateStart: 'm2d', dateEnd: 'today' },
            {text: '<?php echo lang('dashboards_quarter_to_date');?>', dateStart: 'q2d', dateEnd: 'today' },
            {text: '<?php echo lang('dashboards_year_to_date');?>', dateStart: 'y2d', dateEnd: 'today' }
        ],
        presets: {
            allDatesAfter: '<?php echo lang('dashboards_all_dates_from_first');?>'
        },
        altFields:'widgetDate_<?php echo $widget_id;?>',
        datepickerOptions: {
            changeMonth: true,
            changeYear: true,
            maxDate: Date.today()
        },
    });
    parent.$('#widgetDate_<?php echo $widget_id;?>S').val('<?php echo $options->widgetStartDate;?>');
},10);
{/eval}

Say I need to do a localization for french, can someone give me step-by-step guide to do this for the above code. Any help will be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

地狱即天堂 2025-01-12 23:22:23

您可以使用日期范围选择器选项。

这是意大利语本地化:

$('#inputPeriodo').daterangepicker({
    presetRanges: [
                    { text: 'oggi', dateStart: 'today', dateEnd: 'today' },
                    { text: 'ieri', dateStart: 'today-1days', dateEnd: 'today-1days' },
                    { text: 'ultimi 7 giorni', dateStart: 'today-7days', dateEnd: 'today' } ],
    presets: {
        specificDate: 'giorno specifico',
        allDatesBefore: 'prima del',
        allDatesAfter: 'dopo il',
        dateRange: 'intervallo'
    },
    rangeStartTitle: 'data inizio',
    rangeEndTitle: 'data fine',
    nextLinkText: 'mese successivo',
    prevLinkText: 'mese precedente',
    doneButtonText: 'fatto',
    dateFormat: 'dd/mm/yy', 
    datepickerOptions: {
        prevText: '<Prec',
        nextText: 'Succ>',
        monthNames: ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno',
            'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'],
        monthNamesShort: ['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu',
            'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'],
        dayNames: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'],
        dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'],
        dayNamesMin: ['Do', 'Lu', 'Ma', 'Me', 'Gi', 'Ve', 'Sa']
    }
});

You can use the daterangepicker options.

this is the italian localization:

$('#inputPeriodo').daterangepicker({
    presetRanges: [
                    { text: 'oggi', dateStart: 'today', dateEnd: 'today' },
                    { text: 'ieri', dateStart: 'today-1days', dateEnd: 'today-1days' },
                    { text: 'ultimi 7 giorni', dateStart: 'today-7days', dateEnd: 'today' } ],
    presets: {
        specificDate: 'giorno specifico',
        allDatesBefore: 'prima del',
        allDatesAfter: 'dopo il',
        dateRange: 'intervallo'
    },
    rangeStartTitle: 'data inizio',
    rangeEndTitle: 'data fine',
    nextLinkText: 'mese successivo',
    prevLinkText: 'mese precedente',
    doneButtonText: 'fatto',
    dateFormat: 'dd/mm/yy', 
    datepickerOptions: {
        prevText: '<Prec',
        nextText: 'Succ>',
        monthNames: ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno',
            'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'],
        monthNamesShort: ['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu',
            'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'],
        dayNames: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'],
        dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'],
        dayNamesMin: ['Do', 'Lu', 'Ma', 'Me', 'Gi', 'Ve', 'Sa']
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文