• Hi Elvin,

    I’m struggling to get this “1 Comment” count translated into German.

    Things that I checked already:
    – Site language set to “German”
    – User language setting = “German”

    What else am I missing?

    Any advice is much appreciated.

    Best regards,
    Jan

    • This topic was modified 4 years, 7 months ago by Jan.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Elvin

    (@ejcabquina)

    Hi Jan,

    Can you share the translation plugin you’re using?

    You can translate it with filters. See Tom’s example here – https://wpshowposts.com/support/topic/translation-3/#post-9809

    And to expand further:

    add_filter( 'gettext', 'wpsp_translate_text', 10, 2 );
    function wpsp_translate_text( $text, $domain ) {
        if ( 'Leave a comment' === $text && 'wp-show-posts' == $domain ) {
            return 'Your translation for Leave a comment';
        } if ( '1 Comment' === $text && 'wp-show-posts' == $domain ) {
            return 'your translation for 1 Comment';
        } if ( '% Comments' === $text && 'wp-show-posts' == $domain ) {
            return 'your translation for # Comments';
        }
    
        return $text;
    }
    Thread Starter Jan

    (@locke85)

    Hi Leo,

    thanks for getting back. I added a filter in the function.php as a temp. work around.

    Re your question: I prefer not to use a translation plugin. Instead I usually translate po-files offline (App = PoEdit) and then use FTP upload to embed them into the child theme directory.

    Meanwhile I downloaded the German translation file from the Translating WP site. Then I created a new subfolder called “wp-show-posts” in “wordpress/wp-content/themes/generatepress_child”. Is this where I dump the po- and mo-file in order for the translations to take effect?

    Thanks,
    Jan

    Plugin Support Elvin

    (@ejcabquina)

    Since this is a plugin, I believe you’ll need to add the file on the plugin’s folder instead. 😀

    (create a /languages folder on wp-show-posts plugin folder.)

    Thread Starter Jan

    (@locke85)

    Hi Leo,

    meanwhile, I created the suggested subfolder and dumped the DE-language files into it (see screenshot)

    I also removed the filter (temp work around) from the function.php file.

    The DE terms from the language file are still not being displayed on the respective page (see bottom of the screenshot).

    What am I missing?

    Thanks,
    Jan

    • This reply was modified 4 years, 6 months ago by Jan.
    Plugin Support Elvin

    (@ejcabquina)

    Try putting it on /wp-content/languages/plugins/ folder instead.

    Let us know how it goes. 😀

    Thread Starter Jan

    (@locke85)

    Hi Elvin,

    my initial reply obviously did not get through. So I’ll give it another try.

    I did move the DE-language file into the suggested folder.

    Unfortunately, the EN version of the comment-link text would still remain ;-/ (Caches have been cleared, following the saying of a wise man ;-).

    Just to be sure I also checked…

    (1) the function.php again for any filters that may overwrite the translation files –> nothing
    (2) the website settings –> language = German
    (3) the user settings –> language = German
    (4) browser settings –> language German

    What am I missing?

    Thanks,
    Jan

    • This reply was modified 4 years, 4 months ago by Jan.
    • This reply was modified 4 years, 4 months ago by Jan.
    Plugin Support Elvin

    (@ejcabquina)

    I forgot to mention about the plugin’s header as well.

    https://developer.ww.wp.xz.cn/plugins/internationalization/how-to-internationalize-your-plugin/#domain-path

    You’ll have to do this on the plugin’s wp-show-posts.php after you’ve added the /language folder.

    https://github.com/tomusborne/wp-show-posts/blob/1ff2257b0e8f5b899dd5f682979733cc36bb48ea/wp-show-posts.php#L2-L12

    Thread Starter Jan

    (@locke85)

    Hi Elvin,

    sorry for not getting back earlier.

    Meanwhile I added the Domain Path: /languages string to the wp-show-posts.php.

    I also checked the language folder. The path seems correct and the language files are stored inside also. See screenshot

    The german translation still does not show up. See bottom of this page.

    What am I missing?

    Thanks,
    Jan

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘WP Show Post / Comment count / Translation’ is closed to new replies.