Suffusion, qtranslate: blog title and home link translation

General questions pertaining to how certain issues can be resolved
Forum rules
1. No offensive language and no mocking
2. Please do a thorough search before you post something. Trust us, there is a high probability that the question you are asking has been asked previously.
3. No soliciting. You cannot post here soliciting bids for people offer you quotes, or even offer money to people for some work. You will be moderated if you do so. If you are looking for help, please post your request on http://jobs.wordpress.net or http://codepoet.com
4. Please be reasonable. You are getting software and support. For free. Complicated requests from a general purpose theme are not welcome and some volunteers might lose patience with you.
5. Please do your due diligence. If you posted a query and we answered with a link, take the trouble to go through the link contents.
6. Please post with complete information. Requests for help MUST be accompanied with your URL, particularly if you are asking something like "Why am I seeing a blank space?"

Suffusion, qtranslate: blog title and home link translation

Postby mtheo » 05 Sep 2012, 08:37

I am a big fan of Suffusion, and qTranslate as well.

I had the problem to display the blog title and description in two different languages. Moreover, I did not like that after pressing the “Home” link button, leaving a comment or using the search box, always the site was reset to the default language.

This morning, I have decided to find a solution. Since the solution I found seems general enough, I want to share with all of you and propose to Sayontan to merge properly in the next Suffusion distribution.

Mainly, I defined the function suffusion_home_url() for getting properly the home URL (based on the language selected by the user) and then, where it was needed, I substituted the call to the function home_url() with the new one. This is the main change to Suffusion 4.3.1:
Code: Select all
Index: functions/actions.php
===================================================================
--- functions/actions.php   (revision 118)
+++ functions/actions.php   (revision 119)
@@ -173,6 +173,16 @@
    }
 }
 
+function suffusion_home_url() {
+   $home_link = home_url();
+   if (function_exists('icl_get_home_url')) {
+      $home_link = icl_get_home_url();
+   } else if (function_exists('qtrans_getLanguage')) {
+      $home_link .= '/'.qtrans_getLanguage().'/';
+   }
+   return $home_link;
+}
+
 function suffusion_display_header() {
    global $suf_sub_header_vertical_alignment, $suf_header_fg_image_type, $suf_header_fg_image, $suf_header_alignment, $suf_sub_header_alignment;
    $display = apply_filters('suffusion_can_display_header', true);
@@ -193,20 +203,18 @@
    <header id="header" class="fix">
    <?php
    $header = ($suf_header_fg_image_type == 'image' && trim($suf_header_fg_image) != '') ? "<img src='$suf_header_fg_image' alt='".esc_attr(get_bloginfo('name'))."'/>" : get_bloginfo('name', 'display');
-   $home_link = home_url();
-   if (function_exists('icl_get_home_url')) {
-      $home_link = icl_get_home_url();
-   }
+   $home_link = suffusion_home_url();
+   $description_qtranslate = html_entity_decode(get_bloginfo('description', 'raw'));
    if ($suf_sub_header_vertical_alignment == "above") {
       ?>
-      <div class="description <?php echo $suf_sub_header_alignment; ?>"><?php bloginfo('description');?></div>
+      <div class="description <?php echo $suf_sub_header_alignment; ?>"><?php _e($description_qtranslate);?></div>
       <<?php echo $header_tag?> class="blogtitle <?php echo $suf_header_alignment; ?>"><a href="<?php echo $home_link;?>"><?php echo $header;?></a></<?php echo $header_tag?>>
    <?php
    }
    else {
       ?>
       <<?php echo $header_tag?> class="blogtitle <?php echo $suf_header_alignment; ?>"><a href="<?php echo $home_link;?>"><?php echo $header;?></a></<?php echo $header_tag?>>
-      <div class="description <?php echo $suf_sub_header_alignment; ?>"><?php bloginfo('description');?></div>
+      <div class="description <?php echo $suf_sub_header_alignment; ?>"><?php _e($description_qtranslate);?></div>
 <?php
    }
    ?>
@@ -927,7 +935,7 @@
          <header class='post-header'>
             <h2 class='posttitle'><?php $title = wp_title(':', false); $title = trim($title); if (substr($title, 0, 1) == ':') { $title = substr($title, 1);} echo $title; ?></h2>
          </header>
-         <form method="get" action="<?php echo home_url(); ?>/" class='search-info' id='search-info'>
+         <form method="get" action="<?php echo suffusion_home_url(); ?>/" class='search-info' id='search-info'>
             <input class="search-hl checkbox" name="search-hl" id="search-hl" type="checkbox"/>
             <label class='search-hl' for='search-hl'><?php _e('Highlight matching results below', 'suffusion');?></label>
             <input type='hidden' name='search-term' id='search-term' value="<?php $search_term = get_search_query(); echo esc_attr($search_term);?>"/>


The files I changed are:
    functions/template.php
    functions/actions.php
    custom/breadcrumb.php
    custom/breadcrumb-page.php

I attach the complete patch for Suffusion 4.3.1
patch_suffusion_4.3.1_qtranslate_enable_multiple_languages_in_blogtitle_and_home_link.zip
Patch for Suffusion 4.3.1. Enable qTranslate to translate the blog title and description and to redirect to the proper "Home" link.
(2.25 KiB) Downloaded 91 times


Hope this help, please, test and let us know.

Cheers!
mtheo
 
Posts: 5
Joined: 16 Mar 2011, 13:22

Return to Support Requests

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests