Topic Closed

Hi everybody;

 

I'm new to this fantastic CMS. Right now I'm working on a new project completely based on GP Easy (this will be my first but not last project whith this tool!).

But, as i'm not a good programmer (just CSS "coinosceur") and graphic designer, i can't figure out how can I translate the dates on the module Blog Made Easy 1, to Spanish.

My client wants to read "Lunes" instead of monday, or "Julio" instead of "July"…

I've read about PHP date function on Spanish and i found this, in order to force PHP to show the spanish date format: 

 

<?php

set_locale(LC_ALL,"[email protected]","es_ES","esp");
echo strftime("%A %d de %B del %Y");

?>

But i can´t figure out where to insert the firt line of code in order to translate the dates…any idea?

Thanks in advance!!!

Edited: 12 years ago#2113

Josh S.
2K Posts
311K Downloads
16 Themes
18 Plugins

You can change the date format without modifying the php by changing the 'Date Format' option in the blog configuration.

The url for the configuration is __your_installation__/Special_Blog?cmd=config or you can click on the "Configuration" link under the "Current Page" heading in the admin toolbar (it will only show up there when you're on a blog page).

12 years ago#2114

Hi Josh;

Thanks for your anwser. But, I'm afraid that the problem is not the date configuration on the GP Easy Blog module.

As far as I know there are several ways of printing the date format, and I understand the configuration tool.
The date is shown on the default language of the server. I can't access the config.php on my hosting provider to change language settings, so, there must be a way of creating an array with the names of the months and each day of the week in order to show the spanish date language, not format.

This is an example code of the arrays we'd create to show the spanish date:
 

function SpanishDate($FechaStamp)
{
  $ano = date('Y',$FechaStamp);
  $mes = date('n',$FechaStamp);
  $dia = date('d',$FechaStamp);
  $diasemana = date('w',$FechaStamp);

  $diassemanaN= array("Domingo","Lunes","Martes","Miércoles",
                      "Jueves","Viernes","Sábado"); $mesesN=array(1=>"Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio",
                 "Agosto","Septiembre","Octubre","Noviembre","Diciembre");
  return $diassemanaN[$diasemana].", $dia de ". $mesesN[$mes] ." de $ano";
}

So i could get " Viernes, 8 de Julio, 2011" instead of "Friday, 8 July 2011"

 

Edited: 12 years ago#2136

Stano
483 Posts
16.6K Downloads
1 Themes
1 Plugins

Hello, you can open the SimpleBlog.php and SimpleBlogCommon.php in text editor and do a search for this string:    ['date_format']

and then replace the found lines with your function call. So it are these 3 lines:

in SimpleBlog.php

433 echo $this->SpanishDate($post['time']);

628 echo $this->SpanishDate($comment['time']);

in SimpleBlogCommon.php

559 echo $this->SpanishDate($post['time']);

and then also copy+paste your function into SimpleBlogCommon.php's class. It should work then. Don't forget to save it as utf-8.

Edited: 12 years ago#2156

Hi Stano;

Thank you very much for your answer. I'm a total disabled on PHP!!!.

Any way, after being ill at home since the last three days, I've read your instructions and now it works perfect!!!.

As soon as i have uploaded the site, I'll send a link !!.

Thanks again!!

12 years ago#2185

By the way;

 

I've followed upo the instructions in order to adapt to the spanish date scriptthe Plugin Simple Blog 1, and it also works (awesome, being me the one who made the mods!!).

And know, one step further: let's suppose that i'm trying to make a multilingual web site.

By the moment the way i'm doing it is by crating a menu tree in wich the first levels are occupied only by the language links, and all the sub links are the contents in each language.

Is there any way of making the blog show the date in the desired language?

12 years ago#2186

Stano
483 Posts
16.6K Downloads
1 Themes
1 Plugins

Hi Pepe, yes it is possible, but it takes much more time and effort than the previous example.

At first, you should have two layouts - one for Spanish pages and one for English pages. Assign each english page the alternative layout.

Then you should create some custom menu for english layout. Then insert Blog (Special page) to the menu as an "External link" and set: /index.php/Blog?lang=es

Then you should modify again the source code of blog, to be able to handle this new url-parameter:

in SimpleBlog.php

433 echo ($this->blogData['lang']=='es')? $this->SpanishDate($post['time']):date($this->blogData['date_format'],$post['time']);

628 echo ($this->blogData['lang']=='es')? $this->SpanishDate($comment['time']):date($this->blogData['date_format'],$comment['time']);

& insert the line #21:    parse_str($_SERVER['QUERY_STRING']); $this->blogData['lang'] = isset($lang)? $lang:'en';

in SimpleBlogCommon.php

559 echo ($this->blogData['lang']=='es')? $this->SpanishDate($post['time']):date($blog_config['date_format'],$post['time']);

+again attach to the script the SpanishDate() function...

and then you should search for common::link function call (inside both .php files) and append to her each 3rd parameter this string:  .'&lang=' .$this->blogData['lang'] ,

respectively only 'lang=' .$this->blogData['lang']  ,if none specified. Then save and it should work... Have a nice day :-)

Edited: 12 years ago#2187

Topic Closed

 

News

elFinder 2.1.50 in Upcoming Release
12/28/2019

A new release for Typesetter is in the works with a lot of improvements including the ... Read More

Typesetter 5.1
8/12/2017

Typesetter 5.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

More News

Log In

  Register