multilingual search ???

Having Problems? Need Help? Post here!

multilingual search ???

Postby Juan » Fri Jul 18, 2008 9:27 am

Thanks for the best multilingual plugin!
My question: Is there a way to have multilingual search results?
I use the "adcanced search plugin" and an individual search.php. Now I want of course to have different languages in the result page.
I tried qtrans_getLanguage in the search.php, but it does not work.
Thanks for your help ...
Juan
 

Re: multilingual search ???

Postby Juan » Fri Jul 18, 2008 9:51 am

Oh,yes: And the same is for the 404.php ...
Juan
 

Re: multilingual search ???

Postby Qian Qin » Sun Aug 03, 2008 12:49 pm

if you are accessing the search.php directly like /search.php?q=foo then it won't work. it has to go through the WP engine or qTranslate won't be able to detect the language.
Qian Qin
Site Admin
 
Posts: 964
Joined: Thu Jun 19, 2008 12:14 pm
Location: Germany

Re: multilingual search ???

Postby Guest » Tue Dec 02, 2008 3:12 pm

Hello,

I also have a problem with the search function of this wonderfull plugin.
I use actual WP 2.6.5.
Everything works fine instead of search function.
My theme is using the following code inside "header.php":

[code=php]
<form id="searchform" method="get" action="<?php bloginfo('url'); ?>">
<div>
<label for="s"><?php _e('Search'); ?></label>
<input type="text" name="s" id="s" size="15" value="Livesearch" onblur="if(this.value=='') this.value='Livesearch';" onfocus="if(this.value=='Livesearch') this.value='';"/>
<button type="submit"><img src="<?php bloginfo('template_url'); ?>/images/cerca.jpg" alt="search" /></button><!--<input type="submit" value="<?php _e('Search]'); ?>" />-->
</div>
</form>
[/code]

Additional I have "search.php" with this code
[code=php]
<div class="post" id="post-<?php the_ID(); ?>">
<div class="posttitle">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<p class="post-info">
Written in <?php the_category(', ') ?> on <?php the_time('d.m.Y') ?> <?php edit_post_link('edit', '', ''); ?> | <?php comments_popup_link('0 comments &#187;', ' comment &#187;', '% comments &#187;'); ?> </p>
</div>

<div class="entry">
<?php the_excerpt(); ?>
</div>
<?php comments_template(); ?>
</div>
[/code]

Regardless in which language you are reading the content at the moment, if you are searching for a keywoard there will be always results presented in the default language.
If you then press another language flag for specific results in the desired language, you will still get the desired results presented in right language.

Now my question is how you can modify so that you must't switch?
If you are reading German and are searching for a keyword the search results should be also in German language.

Please help me. I don't find the right way on my own.

Thank you in advance.

Regards
newbie_2004
Guest
 

Re: multilingual search ???

Postby alarch » Sun Jan 25, 2009 10:20 pm

I have exactly the same problem as the one described above - if I search for terms in a non-default language whilst displaying a page in the non-default language the results are displayed in the default language. I've tried a variety of search plugins as well as using the default WordPress search function - with the same results every time. Has anyone had any success with any of the search plugins available? If they needed to do any customization what was it?
alarch
 

Re: multilingual search ???

Postby fajtbros » Sun Feb 15, 2009 4:38 pm

There is a solution:

Open searchform.php, find this:

Code: Select all
<form method="get" id="searchform" action="<?php bloginfo('home'); ?>">


Replace with:

Code: Select all
<form method="post" id="searchform" action="<?php bloginfo('home'); ?>">


That's it, I hope it helps, works for me ;)
fajtbros
 
Posts: 2
Joined: Sun Feb 15, 2009 4:33 pm

Re: multilingual search ???

Postby princessdesign » Sun Feb 15, 2009 6:30 pm

this solution helped my problem with displaying the correct language in search results page (top search form is for English language and the second is for Slovenian):
Code: Select all
<?php if (qtrans_getLanguage()=="en"): ?>
                  <div id="search">
                                                 
                                    <form method="get" id="searchform" action="<?php echo qtrans_convertURL('', 'en'); ?>">
                                       
                              <div><label for="s" class="none">Search:</label>
                              <input type="text" name="s" id="s" class="search_input" value="" />

                              
                              <label for="searchsubmit" class="none">Search</label>
                              <input type="submit" id="searchsubmit" class="submit_input" value="Search" /></div>
                                       
                                    </form>
            </div>
<?php endif; ?>

<?php if (qtrans_getLanguage()=="sl"): ?>
                           <div id="search">
                                                 
                                    <form method="get" id="searchform" action="<?php echo qtrans_convertURL('', 'sl'); ?>">
                                       
                              <div><label for="s" class="none">Iskanje:</label>
                              <input type="text" name="s" id="s" class="search_input" value="" />

                              
                              <label for="searchsubmit" class="none">I&#353;&#269;i</label>
                              <input type="submit" id="searchsubmit" class="submit_input" value="I&#353;&#269;i" /></div>
                                       
                                    </form>
            </div>
<?php endif; ?>


The key is in the action - it tells wordpress and qtranslate which language to show
princessdesign
 
Posts: 2
Joined: Sun Feb 15, 2009 6:25 pm

Re: multilingual search ???

Postby marcelziul » Sun Mar 01, 2009 9:59 am

I'm also encountering the same problem. I have checked my source, checked my searchform.php and there seems to be nothing wrong with them, as the action for the search is defined correctly and apparently should point to the correct language. I have even tried the above solution by princessdesign and have not been successful. Any thoughts?
marcelziul
 
Posts: 1
Joined: Sat Feb 28, 2009 9:02 am

Re: multilingual search ???

Postby fajtbros » Sun Mar 01, 2009 2:07 pm

Have you tried my solution?

Open searchform.php, find this:


Code: Select all
<form method="get" id="searchform" action="<?php bloginfo('home'); ?>">




Replace with:


Code: Select all
<form method="post" id="searchform" action="<?php bloginfo('home'); ?>">
fajtbros
 
Posts: 2
Joined: Sun Feb 15, 2009 4:33 pm

Re: multilingual search ???

Postby alarch » Tue Mar 03, 2009 12:29 pm

I managed to get the Advanced Search Plugin to work multilingually by modifying form.php. I added the following lines:

Code: Select all
      $actionurl = get_bloginfo('home');
      $actionurl = qtrans_convertURL($actionurl, $locale);
      $form .= "<form id='{$this->id_prefix}form' action='".$actionurl."' method='get'>";


replacing:

Code: Select all
      $form .= "<form id='{$this->id_prefix}form' action='".get_bloginfo('home')."' method='get'>";


This would need to wrapped in function_exists conditionality if you envisage the possibility of disabling qTranslate down the line.
alarch
 
Posts: 13
Joined: Mon Mar 02, 2009 12:56 pm

Next

Return to qTranslate Support Forum

Who is online

Users browsing this forum: No registered users and 4 guests