Okay, on closer inspection, Tribe__Events__Asset__Bootstrap_Datepicker.php has been deprecated, so it’s probably not directly causing this issue.
I cobbled something together to force datepicker to translate. There has to be better ways to do this, but this was the best I could come up with for now. So if you know a better way, please share.
For what it’s worth, I have The Events Calendar version 4.6.22.1 and WPML Multilingual CMS version 4.0.6
First I downloaded the “bootstrap-datepicker.zh-TW.js” file from https://github.com/uxsolutions/bootstrap-datepicker/tree/master/js/locales and renamed it “bootstrap-datepicker.zh-HK.js”
Then I changed the script inside this file to:
if (tribe_bootstrap_datepicker_zh_strings.current_icl_language_code == 'zh') {
;(function($){
$.fn.datepicker.dates['zh-HK'] = {
days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
daysShort: ["週日", "週一", "週二", "週三", "週四", "週五", "週六"],
daysMin: ["日", "一", "二", "三", "四", "五", "六"],
months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
monthsShort: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
today: "今天",
format: "yyyy年mm月dd日",
weekStart: 1,
clear: "清除"
};
}(jQuery));
} else {
;(function($){
$.fn.datepicker.dates['zh-HK'] = {
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
today: "Today",
monthsTitle: "Months",
clear: "Clear",
weekStart: 1,
format: "dd/mm/yyyy"
};
}(jQuery));
}
I put this in plugins/the-events-calendar/vendor/bootstrap-datepicker/js
I open bootstrap-datepicker.min.js from that same directory, and changed language:"en" to language:"zh-HK"
I open the Assets.php file in plugins/the-events-calendar/src/Tribe and changed
array( 'tribe-events-bootstrap-datepicker', 'vendor/bootstrap-datepicker/js/bootstrap-datepicker.js', array( 'jquery' ) ),
to
array( 'tribe-events-bootstrap-datepicker', 'vendor/bootstrap-datepicker/js/bootstrap-datepicker.js', array( 'jquery' ) ),
array( 'tribe-events-bootstrap-datepicker-zh', 'vendor/bootstrap-datepicker/js/bootstrap-datepicker.zh-HK.js', array( 'tribe-events-bootstrap-datepicker' ) ),
I added this to my theme’s functions.php:
// TRANSLATE DATE PICKER
wp_register_script( 'tribe-events-bootstrap-datepicker-zh', '/wp-content/plugins/the-events-calendar/vendor/bootstrap-datepicker/js/bootstrap-datepicker.zh-HK.js' );
// Localize the script with new data
$translation_array = array(
'current_icl_language_code' => ICL_LANGUAGE_CODE
);
wp_localize_script( 'tribe-events-bootstrap-datepicker-zh', 'tribe_bootstrap_datepicker_zh_strings', $translation_array );