Support » Themes and Templates » template utilising gettext __() & _e()

  • Hi,

    I have created my own template and was now trieing to utilise the gettext functions in order to be able to use the same template for english and german blogs. I have added my phrases to the german de_DE.po file and generated a file. I have stored both files in /wp-content/languages/ and set the lang variable in the config file to de_DE. However the translation does not work properly. The following code in my template:

    <div class="post_subline"><?php _e('Posted by'); ?> <?php the_author();?> <?php _e('on'); ?> <?php the_time(__('l, F jS, Y')) ?> | <?php printf(__('Posted in %s'), get_the_category_list(', ')); ?></div>

    results in that output:

    Verfasst von admin am Sonntag, Januar 11th, 2009 | Posted in Allgemein | No Comments ยป

    which is only partly german ๐Ÿ™

    Any Ideas how I can fix this problem or start debuging it?


Viewing 1 replies (of 1 total)
  • Start by looking at this bit, and see if you can simply echo instead:
    <?php printf(__('Posted in %s'), get_the_category_list(', ')); ?>
    Something like:
    <?php _e('Posted in %s',TEXT_DOMAIN_NAME) . echo(the_category(', ')); ?>
    Sidenote: you’re not using the textdomain feature – e.g. with German you could have separate translations for users in Switzerland, Austria and Germany. As you leave it out, it’ll pull out what it has, wherever – even from WP’s own .mo file.

    Hope that gets you moving along faster/better… I’m not a PHP coder – just looking at lots of Gettext-ready PHP files when I’m translating myself.

Viewing 1 replies (of 1 total)
  • The topic ‘template utilising gettext __() & _e()’ is closed to new replies.