Hello,
I purchased a WP events plugin for a project and translated everything into Spanish, but I have a problem with unix timestamps as they're based on strtotime() which only accepts English strings. This is the function that generates the event timestamp:
private function save_timestamp() {
$date_flag = false;
$date = date_parse( $this->date );
if( $date["error_count"] == 0 && checkdate( $date["month"], $date["day"], $date["year"] ) )
$date_flag = true;
if( $date_flag ) {
$timestamp = strtotime( $this->date );
}
else {
$event_unix = get_post_meta( $this->post_id, 'event-unix', true );
if( ! empty( $event_unix ) )
$timestamp = $event_unix;
else
$timestamp = current_time( 'timestamp' );
}
update_post_meta( $this->post_id, 'event-unix', $timestamp );
}
So, being the datepicker in Spanish, events are getting current dates (event creation date).
The web is full of documentation about displaying unix dates in other languages, but I've not been able to find anything that does the opposite. I tried putting setlocale(LC_TIME, "es_ES") into the above function... I guess this is not the way to go.
This is what I'm using to translate the jquery datepicker (as you can see I did not event tried to change the dateformat, just the texts so users understand what they're doing):
$.datepicker.regional['es'] = {
closeText: "Cerrar", // Display text for close link
prevText: "Anterior", // Display text for previous month link
nextText: "Siguiente", // Display text for next month link
currentText: "Hoy", // Display text for current month link
monthNames: ["Enero","Febrero","Marzo","Abril","Mayo","Junio",
"Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"], // Names of months for drop-down and formatting
monthNamesShort: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"], // For formatting
dayNames: ["Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado"], // For formatting
dayNamesShort: ["Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab"], // For formatting
dayNamesMin: ["Do","Lu","Ma","Mi","Ju","Vi","Sa"], // Column headings for days starting at Sunday
//weekHeader: "Sm", // Column header for week of the year
//dateFormat: "mm/dd/yy", // See format options on parseDate
//firstDay: 1, // The first day of the week, Sun = 0, Mon = 1, ...
//isRTL: false, // True if right-to-left language, false if left-to-right
//showMonthAfterYear: false, // True if the year select precedes month, false for month then year
//yearSuffix: "" // Additional text to append to the year in the month headers
};
$.datepicker.setDefaults($.datepicker.regional['es']);
Any help would be greatly appreciated.