• Resolved levani01

    (@levani01)


    Hello

    I’m using Gengo plugin and have a problem with translating “Read more” test.

    Texts are translated by Gengo using this code

    <?php
    	if (is_language('en')) echo "You are reading in English";
    	elseif (is_language('ja')) echo "You are reading in Japanese";
    	else echo "You are seeing all posts...";
    ?>

    How can I join above code with

    <?php the_content('Read more...'); ?>

    to make possible to translate this “Read more” text?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter levani01

    (@levani01)

    Somebody help please

    Hello,

    In order to translate anything in your theme or in plugins you should turn to the GNU gettext localization framework used by WordPress(read more in the codex).

    Thus, if you need to translate a text string you should use:

    <?php
    // This returns the translated string for use in PHP
    __('Translate me');
    // This echoes out the string
    _e('Translate me');
    ?>

    So, to translate parameters of the_content you should pass them like so:

    <?php the_content(__('Read more...', 'your-theme-textdomain-name')); ?>

    if you need to pass additional parameters, you have to separate them properly:

    <?php the_content('<p class="readmore-link">' . __('Read more...', 'your-theme-textdomain-name') . '
    '); ?>

    and then use poEdit (or similar tool) to translate your theme. And ofcouse don’t forget to load the theme textdomain in your functions.php file:

    <?php load_theme_textdomain('your-theme-textdomain-name'); ?>

    Good luck 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Translate the_content using Gengo’ is closed to new replies.