This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Focus Premium theme translation

Resolved 14 replies themetheme-focus
11 years ago · Last reply by Andrew Misplon 11 years ago

Hello!
I would like to know, is it possible to translate Focus theme texts? For example, “Post Comment” button, “Recent posts” etc. How I can translate it in my native language?
Thank You!

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

14
  1. Andrew Misplon Staff 11 years, 11 months ago

    Hi

    We’ll hopefully have documentation on this soon.

    1. Find the .pot file in the languages folder with Focus at wp-content/themes/focus
    2.Use http://www.poedit.net/ to create a .mo and .po file. These files must be named as follows:
    de_DE.mo and de_DE.po
    The above is an example using German.
    3. Place these files back in your languages folder in wp-content/themes/focus
    4. In your WordPress root find wp-config.php and change WPLANG to your language. E.g: define( ‘WPLANG’, ‘de_DE’ );
    http://codex.wordpress.org/Editing_wp-config.php#Language_and_Language_Directory

  2. Andrew Misplon Staff 11 years, 11 months ago

    The above however won’t survive an upgrade of Focus. To do this properly create a Focus child theme: https://codex.wordpress.org/Child_Themes.

    Within your child theme create a functions.php file and place the following in that file:

    <?php
    function focus_child_set_text_domain(){
    load_theme_textdomain( 'focus', get_stylesheet_directory() . '/languages' );
    }
    add_action('after_setup_theme', 'focus_child_set_text_domain', 15);

    Then place your .po and .mo files in a languages folder in your child theme.

    Your changes will now be upgrade safe.

  3. ignorance 11 years, 11 months ago

    Thank You very much, so far done.
    But how can I translate, for exaple, these values:
    http://postimg.org/image/v218etgfz/
    http://postimg.org/image/6mt0drhj3/ ?
    I tried to add in my language .po file “Leave a Reply” and translate it, but no changes in page…

  4. Andrew Misplon Staff 11 years, 11 months ago

    Recent Posts is possibly the title of a widget so you should check under Appearance > Widgets for that. Leave a reply is by default part of

    <?php comment_form(); ?>

    to edit it you’ll need to insert the comments.php file into your child theme and change

    <?php comment_form(); ?>

    to:

    <?php 
    		$comments_args = array(
            // change the title of the reply section
            'title_reply'=>'Leave a Comment',
    		);
    		comment_form($comments_args);
    	?>

    And change my Leave a Comment to whatever you’d like that to read.

  5. ignorance 11 years, 11 months ago

    Sorry, didn’t notice widget title.
    Thank You, that’s clear about “Leave a reply”.
    Embarrassed to ask more, but also how I can translate:
    “Your email address will not be published. Required fields are marked *”
    “Name, Email, Website” and “Post Comment” button in comment form. http://postimg.org/image/cvx7x6k1x/
    And last, “Search Results” and “Search” button. http://postimg.org/image/sgc4pihs3/

    I hope this isn’t annoying… but I don’t have any coding skills, so I can’t do this by myslef.

  6. Andrew Misplon Staff 11 years, 11 months ago

    No problem. Try this instead, to get to all those strings:

    <?php
    $comments_args = array(
        // change the title of send button 
        'label_submit' => 'Send',
        // change the title of the reply section
        'title_reply' => 'Write a Reply or Comment',
        // 
        'title_reply_to' => __('Leave a Reply to %s'),
        //
        'cancel_reply_link' => __('Cancel Reply'),
        // remove "Text or HTML to be displayed after the set of comment fields"
        'comment_notes_after' => '',
        // redefine your own textarea (the comment body)
        'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x('Comment', 'noun') . '</label><br /><textarea id="comment" name="comment" aria-required="true"></textarea></p>',
        //
        'author' => '<p class="comment-form-author">' . '<label for="author">' . __('Name', 'domainreference') . '</label> ' . ($req ? '<span class="required">*</span>' : '') . '<input id="author" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" size="30"' . $aria_req . ' /></p>',
        //
        'email' => '<p class="comment-form-email"><label for="email">' . __('Email', 'domainreference') . '</label> ' . ($req ? '<span class="required">*</span>' : '') . '<input id="email" name="email" type="text" value="' . esc_attr($commenter['comment_author_email']) . '" size="30"' . $aria_req . ' /></p>',
        //
        'comment_notes_before' => '<p class="comment-notes">' . __('Your email address will not be published.') . ($req ? $required_text : '') . '</p>',
        //
        'url' => '<p class="comment-form-url"><label for="url">' . __('Website', 'domainreference') . '</label>' . '<input id="url" name="url" type="text" value="' . esc_attr($commenter['comment_author_url']) . '" size="30" /></p>',
        //
        'comment_notes_before' => '<p class="comment-notes">' . __('Your email address will not be published.') . ($req ? $required_text : '') . '</p>',
        // 
        'label_submit' => __('Post Comment')
    );
    comment_form($comments_args);
    ?>

    If you take a look at search.php you’ll see everything within the form is translatable so you should be able to translate the Search button. To sort out the page title please drop search.php into your child theme and try replacing line 15 with your own title.

  7. ignorance 11 years, 11 months ago

    I insert
    ‘Sūtīt’,
    // change the title of the reply section
    ‘title_reply’ => ‘Komentēt’,
    //
    ‘title_reply_to’ => __(‘Atbildēt %s’),
    //
    ‘cancel_reply_link’ => __(‘Atcelt’),
    // remove “Text or HTML to be displayed after the set of comment fields”
    ‘comment_notes_after’ => ”,
    // redefine your own textarea (the comment body)
    ‘comment_field’ => ” . _x(‘Comment’, ‘noun’) . ”,
    //
    ‘author’ => ” . ” . __(‘Vārds’, ‘domainreference’) . ‘ ‘ . ($req ? ‘*’ : ”) . ”,
    //
    ’email’ => ” . __(‘E-pasts’, ‘domainreference’) . ‘ ‘ . ($req ? ‘*’ : ”) . ”,
    //
    ‘comment_notes_before’ => ” . __(‘E-pasts nebūs redzams citiem’) . ($req ? $required_text : ”) . ”,
    //
    ‘url’ => ” . __(‘Website’, ‘domainreference’) . ” . ”,
    //
    ‘comment_notes_before’ => ” . __(‘E-pasts nebūs redzams citiem’) . ($req ? $required_text : ”) . ”,
    //
    ‘label_submit’ => __(‘Apstiprināt’)
    );
    comment_form($comments_args);
    ?>
    in child theme comments.php, but some fields doesn’t change: http://postimg.org/image/w1ejf87nr/
    I do something wrong?

  8. ignorance 11 years, 11 months ago

    http://postimg.org/image/gwqljlkul/full/ – that’s what I translated in code

  9. Andrew Misplon Staff 11 years, 11 months ago

    You’ll need to insert exactly what I pasted so originally you had:

    <?php comment_form(); ?>

    you’ll need to replace that with the entire function and array I provided above.

  10. ignorance 11 years, 11 months ago

    I did all like you said. Maybe you can take a look at that comments file: http://www.speedyshare.com/GVGdH/comments.php
    And here is result: http://postimg.org/image/4na3r5gjj/ Name, e-mail and website names doesn’t change.

  11. Andrew Misplon Staff 11 years, 10 months ago

    Greg has shown me the correct way we should be doing this. Please revert comments.php back to

    <?php comment_form(); ?>

    then create a file for your child theme called functions.php and place in it the following:

    <?php
    function focus_child_filter_comment_form($defaults) {
    $commenter = wp_get_current_commenter();
    $req      = get_option( 'require_name_email' );
    $aria_req = ( $req ? " aria-required='true'" : '' );
    $defaults['fields']['author'] = '<p class="comment-form-author">' . '<label for="author">' . __('Vārds', 'domainreference') . ($req ? '<span class="required">*</span>' : '') . '</label> ' . '<input id="author" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" size="30"' . $aria_req . ' /></p>';
    return $defaults;
    }
    add_filter('comment_form_defaults', 'focus_child_filter_comment_form');

    If the site is live send me a link for where you after that and I’ll assist further if required.

    We’ll hopefully have these items in the Focus pot file in a near future update.

  12. ignorance 11 years, 10 months ago

    Thank you, now it works. I would be very grateful if you could help with all those translations.
    Here is site: http://test.tutv.lv/kas-jauns-tukuma-03-04-2014/

    Include this in update would be good. :)

  13. Plamen 11 years, 3 months ago

    Hello Andrew,
    I have no such file (.po file in the languages folder with Focus at wp-content/themes/focus).
    Where can I find it? My order number is: 57342674546062222

    Regards

Replies on this thread are closed.

Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Have a different question or issue?

Start New Thread