WordPress.org

Ready to get started?Download WordPress

Forums

template utilising gettext __() & _e() (2 posts)

  1. nachtschicht
    Member
    Posted 5 years ago #

    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 de_DE.mo 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?

    Thanks
    Johannes
    :: http://www.security-blog.eu

  2. nv1962
    Member
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic