Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #236408

    Ironic
    Participant

    Hi

    I have an issue with certain text strings still showing in English (my site is in Swedish). I have checked different translation forum posts butI still can’t get this to work for me.

    For instance I have issues with these texts:
    “Nothing to Show Right Now
    It appears whatever you were looking for is no longer here or perhaps wasn’t here to begin with. You might want to try starting over from the homepage to see if you can find what you’re after from there.”

    The word “Search” in the actual search field

    “Category Archive”

    “SEARCH RESULTS FOR “x””

    “Leave a comment” under the titles of blog posts
    ———

    Here’s what I have tried so far:
    I have updated the default.po and default.mo files with poedit and uploaded them to wp-content/Themes/x/framework/lang.

    I have also updated the sv_SE.po and sv_SE.mo files and uploaded them to wp-content/languages.

    I tried out the recommendation from some forum post to update and rename the default.po/mo files to x-fi.po and x-fi.mo and upload them to wpcontent/languages/themes.

    After the above actions didn’t work I also tried to install a plugin (by Loco translation management) to help me edit the PO-files directly within wordpress, and in there the translations are also correct. But still the English texts are somehow overriding these translations.

    From what I can tell the translations are in place in all the po/mo files now, but the translated strings are not showing up on the site.
    FYI: In my wp-config.php it says “define(‘WPLANG’, ‘sv_SE’);”

    So there you have it. I am not a coder, so I’d rather not start editing php-files or try too advanced tricks unless it is really necessary, but I could sure use some help here. Very annoying issue indeed.

    My site is http://www.rudiethefoodie.se, wordpress version 4.1.1–sv_SE, x version 3.2.3.

    Thanks/Karin

    #236524

    Darshana
    Moderator

    Hi there,

    Thanks for writing in! Please follow the instructions below.

    First make sure that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    #1. Copy the file _content-none.php from “X/framework/views/global/” and place it into your Child Theme’s respective location “X-child-{stack}/framework/views/global”. Now open the file and around the line 14 you find
    <h1 class="entry-title"><?php _e( 'Nothing to Show Right Now', '__x__' ); ?></h1>
    You can replace the text ‘Nothing to Show Right Now’ with your translation.
    Around line 17 you can find
    <p><?php _e( "It appears whatever you were looking for is no longer here or perhaps wasn't here to begin with. You might want to try starting over from the homepage to see if you can find what you're after from there.", '__x__' ); ?></p>

    #2. To replace the wording “TYPE AND PRESS ENTER TO SEARCH”, please add the following code into your Child Theme’s functions.php file and replace the wording “New Search Text” with your own content.

    
    add_filter( 'gettext', 'replace_search_string', 20, 3 );
    function replace_search_string( $search_text, $text, $domain ) {
        if ( $text == 'Type and Press &ldquo;enter&rdquo; to Search' ) return __( 'New Search Text', $domain );
        else return $search_text;
    }
    

    #3. Copy _landmark-header.php file from “X/framework/views/{STACK}/” and place it into your Child Theme’s respective location “X-child-{stack}/framework/views/{STACK}/”. Now you can open the file and around line 24 you find

    <h1 class="h-landmark"><span><?php _e( 'Search Results', '__x__' ); ?></span></h1>
     <p class="p-landmark-sub"><span><?php _e( "Below you'll see everything we could locate for your search of ", '__x__' ); echo '<strong>&ldquo;'; the_search_query(); echo '&rdquo;</strong>'; ?></span></p>

    Replace the text with your translation.

    #4. To change “Leave a comment”, add the following code into your child theme’s functions.php file and replace the text “ADD TEXT TO REPLACE WITH Leave a Comment HERE”.

    add_filter('gettext', 'translate_text_to_germen', 20, 3);
    
    function translate_text_to_germen($ttxt, $txt, $d) {
    
       switch ($txt) {
          
          case 'Leave a Comment':
             return 'ADD TEXT TO REPLACE WITH Leave a Comment HERE'; // Change text here
             break;
       }
    
       return $ttxt;
    
    }
    

    #5. Please make sure to follow the instructions here (https://theme.co/x/member/forums/topic/change-child-theme-language/#post-6751) to translate most of the content easily. You will have to use a software like poEdit and create your own translation file based on our default.po template.

    Hope that helps.