Changing Languages
-
Comments:
- here.
There isn’t a way to tell Blogsome you are writing in a different language, but with things like dates, that are generated using Smarty tags, there is a way to replace the English words with those of your chosen language. Where you’d normally use a tag like: {the_time d='l, j F Y'}
, which would generate something like: Thursday, 23rd March 2006, you can set up your template with:
{capture name=the_date}{the_time d='l, j F Y'}{/capture}
Then, assign this captured text to a new variable, after translating each word you know might appear in the text using |replace:"old":"new"
, which you can repeat for each word. For example, to replace all of the day names with their Spanish equivalent, and assign the result to $la_fecha
, I used:
{assign var=la_fecha value=$smarty.capture.the_date|replace:"Monday":"Lunes"|replace:"Tuesday":"Martes"|replace:"Wednesday":"Miércoles"|replace:"Thursday":"Jueves"|replace:"Friday":"Viernes"|replace:"Saturday":"Sábado"|replace:"Sunday":"Domingo"}
Then, wherever you want to use {the_date}
in the Spanish format: {$la_fecha}
. Obviously, you’ll need to repeat this for month names as well, which I will leave as an exercise to the reader.