• Resolved utnalove

    (@utnalove)


    Hello, how can I add the gettext call to this?

    $content = implode(" ",$content).'...<a href="'. get_permalink($post->ID) . '">Read full post</a>

    I have tried this but it doesn’t work:
    $content = implode(" ",$content).'...<a href="'. get_permalink($post->ID) . '">__('Read full post')</a>

    How should it look like?

Viewing 15 replies - 16 through 30 (of 41 total)
  • Thread Starter utnalove

    (@utnalove)

    The define in wp-config is only for the wp-admin pages

    ?

    If I I put define('WPLANG', 'pl_PL'); it reads/uses the pl_PL.po translation file.

    If I put define('WPLANG', 'en_EN'); it uses the English file where there is msgid, but the msgstr is missing.
    So it looks like it works for theme translation as well.

    Moderator keesiemeijer

    (@keesiemeijer)

    In the edit schreen of the codestyling-localization can you see your textdomain “language” in a dropdown box. click it and see if the “Read full post” string is in there. if so click “Generate mo-file”.

    Maybe clear your browsers cache.

    Thread Starter utnalove

    (@utnalove)

    I went to my theme. I clicked on “edit” on the Polish language. In the drop down menu I see there are two possibilities “default” and “language”.
    Language is already set. So I clicked the “generate mo file” button.

    The date of the mo file changed. It was generated.

    However after refreshing the site, the “read full post” is not yet translated.

    What else can I try?

    Thread Starter utnalove

    (@utnalove)

    I have used different browsers, cleared cookies and cache. I tried on Win also with safari. No caching plugins are active.

    Moderator keesiemeijer

    (@keesiemeijer)

    Try it with putting this in your functons.php

    add_action('after_setup_theme', 'my_theme_language');
    function my_theme_language(){
        load_theme_textdomain('language');
    }

    Your language .mo file needs to be in the root of your theme directory (wp-conten/themes/yourtheme/pl_PL.mo)

    Thread Starter utnalove

    (@utnalove)

    Ok, I added that code on my functions.php.
    What does it do?

    My po and mo files are in wp-content/themes/themename/languages/
    Should I copy them (or only the pl_PL.mo) to wp-content/themes/themename/?

    Moderator keesiemeijer

    (@keesiemeijer)

    this will load the texdomain translated strings for a theme.
    if it is in a directory called /languages change it to this:

    add_action('after_setup_theme', 'my_theme_language');
    function my_theme_language(){
        load_theme_textdomain('language',  get_template_directory() . '/languages');
    }
    Thread Starter utnalove

    (@utnalove)

    I did it, thank you. What now?

    Thread Starter utnalove

    (@utnalove)

    I don’t know if it may help. If I search for language stuff in my functions.php I see the following:

    load_theme_textdomain( 'language', TEMPLATEPATH.'/languages/' );
    I don’t knwo if it is the same of the code we just added.

    Moderator keesiemeijer

    (@keesiemeijer)

    If that didn’t work try loading it directly in your theme’s header.php.

    <?php load_theme_textdomain('language', get_template_directory() . '/languages'); ?>

    Keep clearing your browsers cache when doing these steps.

    Thread Starter utnalove

    (@utnalove)

    when adding `<?php load_theme_textdomain(‘language’, get_template_directory() . ‘/languages’); ?>
    ` should I remove the code we just added in the functions.php?

    Thread Starter utnalove

    (@utnalove)

    I added this code in the header.pho in the <head> </head> section.
    I still have the code on the functions.php. Maybe I delete it and retry?

    P.s. I am always clearing cookies, cache and trying new browsers

    Moderator keesiemeijer

    (@keesiemeijer)

    Well I’m stumped. Try your code also without the theme text domain:

    <?php
    $content = implode(" ",$content).'...<a href="'. get_permalink($post->ID) . '">'.__('Read full post') .'</a>';
    ?>

    What theme are you using?

    Thread Starter utnalove

    (@utnalove)

    Try your code also without the theme text domain

    mmm, sorry, I didn’t get it, what do you mean?

    I have 3 questions:
    1: Should I remove the code you told me to add in the functions.php?
    2: Should I remove the code you told me to add in the header.php?
    3: If you want I can create a test site and give you access to it, so that you can test it. I am using the celebritypress5 theme

    Moderator keesiemeijer

    (@keesiemeijer)

    Delete the code from functions.php and header.php. Have you tried the forums of your theme? https://gorillathemes.com/support/

Viewing 15 replies - 16 through 30 (of 41 total)
  • The topic ‘Gettext calls how to – functions.php’ is closed to new replies.