Date formatting not working after installing qTranslate

I just installed qTranslate to have multilingual entries. It’s a really good internationalization plugin, I’ve used it on other WordPress installations before with great results.

After installing it with WordPress 3.0.1 though, the date format for posts wasn’t being parsed, showing instead the raw format:

Posted on %e de %B de %Y by johnny

I found a solution for this on the qTranslate forums:

  • Edit qtranslate_utils.php, line 143 from this:
    $date_parameters[] = '#%#'; $strftime_parameters[] = '%%';
    to this:
    $date_parameters[] = '#%#'; $strftime_parameters[] = '%';

It seems the extra percentage sign makes it so the percentage sign in the format gets interpreted as literal percentage signs and therefore they don’t get parsed by strftime().

The formatting in Spanish and Catalan isn’t completely fixed though, spurious “02UTC” strings are being added after each date component.

Resources

About johnny

I'm a French-born Scot living in Spain. Computers have interested me since I can remember and conveniently I'm now studying a computer science degree. This here is my BLOGOSPHERE OUTLET where I post solutions to problems I've had in the office or any other arbitrary project, hopefully for future reference AND TO BE PICKED UP BY THE BLOGOSPHERE. (not really I hate the 'blogosphere').
This entry was posted in Uncategorized. Bookmark the permalink.

15 Responses to Date formatting not working after installing qTranslate

  1. mirick says:

    jotter more like.. blog?

  2. mirick says:

    it’s a blog is what i’m saying

  3. mirick says:

    you have a blog.

  4. johnny says:

    is this jotter…my blog?

  5. mirick says:

    it’s your blog. you have one.

  6. Thor says:

    Thanks, That helped!

  7. etags says:

    Comenté las líneas144 a 146 y funciona bien para español. espero que sirva .Gracias

  8. etags says:

    De nuevo, tuve que corregir algunas líneas pero creo que de esta manera funciona bien, por cierto es un bug del qtranslate ya que reemplaza los strings donde encuentra los caracteres %d o “d” simplemente , asi que limite esos caracteres para que se pueda tomar los caracteres que se forman de esta forma “%d”, ” d “,”d “,” d”

    Estas son las líneas a cambiar en el archivo qtranslate_utils.php
    línea 143

    [code]
    $date_parameters[] = '#%#'; $strftime_parameters[] = '%';
    foreach($mappings as $df => $sf) {
    //$a = '#(([^%\\\\])'.$df.'|^'.$df.')#';
    $a = "#([^%a-z ]".$df."| ".$df." |^".$df. "| ".$df."$)#";
    $b = ' ${2}'.$sf;
    $date_parameters[] = $a; $strftime_parameters[] = $b;

    }
    [/code]

  9. Dude! Thanks so much for taking the trouble to document this: your proposed solution worked like a charm. My warm best wishes to you.

  10. Pingback: How to avoid dates look like ‘%A %B %e%q, %Y’ in Wordpress blogs? | Calmarius' website

  11. Merciiiiii he estado buscando esta solución mucho rato!!! Genial

  12. Gustavo says:

    Hola etags, por favor, necesito tu ayuda urgente. He hecho los cambios del codigo como has explicado y se me ha arruinado el archivo “qtranslate_utils.php”. Me sale un aviso que dice: “Parse error: syntax error, unexpected ‘>’ in C:\Inetpub\vhosts\grisconcepte.com\httpdocs\web\wp-content\plugins\qtranslate\qtranslate_utils.php on line 130″ y no me deja hacer nada mas. Tuve la precausion de guardar en txt el codigo original; lo restauré pero sigue sin funcionar. Por favor dime que puedo hacer.

  13. Gustavo says:

    Lo he solucionado. No podia restaurarlo, supondo que porque al pegar el codigo en el Bloc de notas me habia desaparecido el formato y cambiaba el número de cada línea. Abrí el archivo con WordPad y copié desde ahí el codigo para despues pegarlo en el archivo del qTranslater.
    Igual te agradeceria si pudieras decirme en que he fallado para que no me funcione el cambio que tu propones.
    Gracias

  14. Pingback: wordpress plugin | Pearltrees

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>