I can not translate the dates into Wordpress theme

5

I have the following site in Wordpress where I have doctors' records with the days in English and I want to change them to Spanish: link I tried the crazy Translate, I tried editing the .po files directly and even went to review the php files of the theme and I could not find the solution. I translated as much as I could and now I have it there as you see it now: "from MONDAY to THRUSDAY". I found in the achivos template of the theme one called practice.php which is where the html of these doctor's files is generated and I have something like this:

$days = '';
if ($object->get('days')) {
$days = $object->get('days');
if (count($days) > 1) {
$last = array_pop($days);
}

And in another file of the "core" folder of the theme called timetable.php I find this function at the beginning:

public function getDays() {
if (!isset(self::$cache['days'])) {
$days = array();
foreach ($this->get('calendar.period') as $time) {
$object = new VTCore_Wordpress_Objects_Array(array(
'id' => strtolower($time->format('l')),
'timestamp' => $time->getTimeStamp(),
'formatted' => $time->format($this->get('calendar.format')),
'iso' => $time->format('Y-m-d\TH:i:sO'),
'label' => $this->get('days.' . strtolower($time->format('l'))),
));
$days[] = $object;
}
self::$cache['days'] = $days;
}
return self::$cache['days'];
}

From there I think it generates the days and we have to add something so that they come out Spanish. Am I ok or did I go to look where I should not?

    
asked by Felipe Pino 30.04.2016 в 17:41
source

2 answers

2

If this is indeed where the day chains are generated, you could pass the variable $days before inserting it to assign its value to self::$cache .

Subject to knowing the names you are returning, you could try a loop and a simple replacement function like this:

$days = array_map(function($nombre) {
    return str_replace(
        ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 
        ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado', 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'], 
        $nombre);
}, $days);

If the names are uppercase or lowercase, simply change the source and output texts.

    
answered by 12.08.2016 в 06:50
1

You have to modify the setlocale here they tell you very well: ( link ) I hope it helps you. Greetings.

    
answered by 12.05.2016 в 12:04