• Resolved Guido

    (@guido07111975)


    Hi,

    I’m working on a update of my theme and want to make the Posted On internationalized, so translators are able to change position of date.

    My old code was:

    <?php _e('Posted on ', 'themename'); ?><a href="<?php the_permalink(); ?>"><?php echo get_the_date(); ?></a>

    Works fine but translators are not able to change position of date.
    So, this is my new code:

    <?php printf( __( 'Posted on %s', 'themename' ), '<a href="<?php the_permalink(); ?>"><?php echo get_the_date(); ?></a>' );  ?>

    But date is not displayed anymore, what am I doing wrong?

    Guido

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Try:

    $string = __( "Posted on <a href='%1$s'>%2$s</a>", 'theme-domain' );
    printf( $string, get_the_permanlink(), get_the_date() );

    Thread Starter Guido

    (@guido07111975)

    Thanks.
    Guess I need to add this in functions file and call it from there?

    If yes, what’s the best way to call it?

    Guido

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Unfortunately I don’t know how your theme is structured/coded. I can only guess but it will be with some meta information or post related information.

    Thread Starter Guido

    (@guido07111975)

    Ok, when I add a function to it:

    function themename_posted_on() {
    $string = __( "Posted on <a href='%1$s'>%2$s</a>", 'themename' ); printf( $string, get_permalink(), get_the_date() );
    }

    How should I load this function in frontend?
    Sorry, I am not are hardcore programmer ??

    Guido

    Thread Starter Guido

    (@guido07111975)

    After hours of trying I guess adding a function to this is not the way to handle this.

    Guido

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    You don’t really need to wrap it in a function definition. If you are going with something like that then you could try:

    function post_date(){
        printf( __(  "Posted on <a href='%s'>%s</a>", 'theme-domain' ),
            get_the_permalink(),
            get_the_date( get_option( 'date_format' )
             ) );
    }

    Do keep in mind that the first parameter will only work with WP3.9+ because of the get_the_permalink function being introduced in 3.9. It will cause a fatal error to an undefined function in prior versions. ??

    Thread Starter Guido

    (@guido07111975)

    Thanks.
    Meanwhile I also got support at my themes.trac page:
    https://themes.trac.www.ads-software.com/ticket/17044#comment:50

    Solved ?? !

    Guido

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Awesome. Glad you got it sorted out.

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Awesome. Glad you got it sorted out.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Internationalize Posted On’ is closed to new replies.