gpt4 book ai didi

javascript - jQuery 日期选择器本地化不起作用

转载 作者:行者123 更新时间:2023-11-30 11:40:44 25 4
gpt4 key购买 nike

为了使用 jQuery datepicker,我为我的 Wordpress 博客站点加载了这些脚本:

<link rel='stylesheet' id='jquery-ui-css-css' href='http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css?ver=4.7.3' type='text/css' media='all' />
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js?ver=4.7.3'></script>
<script type='text/javascript' src='https://code.jquery.com/ui/1.12.1/jquery-ui.js?ver=4.7.3'></script>
<script type='text/javascript' src='http://jquery-ui.googlecode.com/svn/tags/latest/ui/minified/i18n/jquery-ui-i18n.min.js?ver=4.7.3'></script>
<script type='text/javascript' src='http://mywebaddress.com/wp-content/themes/twentyseventeen-child/wpadverts/js/datepicker-ro.js?ver=4.7.3'></script>

我有一段用于本地化datepicker的代码:

<script>
$( function() {
$('#adverts_eventDate').datepicker($.extend({}, $.datepicker.regional['ro'], {
showButtonPanel : true,
dateFormat : 'dd-mm-yy'
}));
} );
</script>

这段代码有效,所以我有一个日期选择器,但它没有本地化(对于罗马尼亚语),它是英文的。我的代码有什么问题?

这就是这些脚本在我的 Wordpress 子主题中排队的方式:

if ( !function_exists( 'wpadverts_plugin_custom_styles' ) ):
function wpadverts_plugin_custom_styles() {
wp_enqueue_script( 'jquery-min-js', 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' );
wp_enqueue_style( 'jquery-ui-css', 'http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css');
wp_enqueue_script( 'jquery-ui-js', 'https://code.jquery.com/ui/1.12.1/jquery-ui.js' );
wp_enqueue_script( 'jquery-ui-i18n-min', 'http://jquery-ui.googlecode.com/svn/tags/latest/ui/minified/i18n/jquery-ui-i18n.min.js' );
wp_enqueue_script( 'jquery-ui-datepicker-ro', get_stylesheet_directory_uri() . '/wpadverts/js/datepicker-ro.js', array( 'jquery' ) );
}
endif;
add_action( 'wp_enqueue_scripts', 'wpadverts_plugin_custom_styles' );

更新

现在我的本地化日期选择器看起来像这样:

<script>
jQuery(function($){
$.datepicker.regional['ro'] = {
closeText: 'Închide',
prevText: '&laquo; Luna precedentă',
nextText: 'Luna următoare &raquo;',
currentText: 'Azi',
monthNames: ['Ianuarie','Februarie','Martie','Aprilie','Mai','Iunie',
'Iulie','August','Septembrie','Octombrie','Noiembrie','Decembrie'],
monthNamesShort: ['Ian', 'Feb', 'Mar', 'Apr', 'Mai', 'Iun',
'Iul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
dayNames: ['Duminică', 'Luni', 'Marţi', 'Miercuri', 'Joi', 'Vineri', 'Sâmbătă'],
dayNamesShort: ['Dum', 'Lun', 'Mar', 'Mie', 'Joi', 'Vin', 'Sâm'],
dayNamesMin: ['Du','Lu','Ma','Mi','Jo','Vi','Sâ'],
weekHeader: 'Săpt',
dateFormat: 'dd.mm.yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''
};
$.datepicker.setDefaults($.datepicker.regional['ro']);
});

$( '#adverts_eventDate' ).datepicker( $.datepicker.regional['ro'] );

</script>

最佳答案

包含这个并尝试

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/i18n/jquery-ui-i18n.min.js"></script>

Fiddle

使用你的 JS

 $(function() {
$('#adverts_eventDate').datepicker($.extend({}, $.datepicker.regional['ro'], {
showButtonPanel: true,
dateFormat: 'dd-mm-yy'
}));
});

关于javascript - jQuery 日期选择器本地化不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42784001/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com