If you have troubles since the update to WordPress 4.5 please read this post before opening a new thread.
July 8, 2013 at 11:11 pm #25907
please have a look at the ajax search (beside menu): http://goo.gl/RtefM
If you switch the language to dutch or english, the result will always use the german strings (try to search for a page title). Did I miss something???
a) I do use a proper configured WPML.
b) I do use PO/MO-Files (WordPress itself, Dutch translation from another Enfold user)
c) Tried to mess around with string translation and also checked with Codestyling Localisation.
Any help is appreciated!July 10, 2013 at 5:36 am #128625
I’ve found: (Purchase code hidden if logged out) /?affiliate_key=K9b6X1wRp9SS”>http://wpml.org/forums/topic/ (Purchase code hidden if logged out) / and probably this helps you. Open up functions-enfold.php and replace
$items .= '<li id="menu-item-search" class="noMobile menu-item menu-item-search-dropdown"><a href="?s=" data-avia-search-tooltip="'.$form.'">'.$avia_config['font_icons']['search'].'</a></li>';
$items .= '<li id="menu-item-search" class="noMobile menu-item menu-item-search-dropdown"><a href="?lang='.ICL_LANGUAGE_CODE.'&s=" data-avia-search-tooltip="'.$form.'">'.$avia_config['font_icons']['search'].'</a></li>';
}July 10, 2013 at 7:19 am #128626
I think Dude has the right way to go about this. Calendar plugin used a similar approach http://trac.theseednetwork.com/ticket/251 For me all the German words are static (in the sense that its always the same set of words in the same positions http://i.imgur.com/LaUGYv6.png these two words, and another phrase blinking quickly sometimes…) so worse comes to worse can even come up with a quick hack and add it right into the do_search function on line 913 of avia.js . Can possibly pull them into the php page (functions_enfold.php line 157, since one of the german words is just a single line above it i believe, the one in h4 tags).
NickJuly 10, 2013 at 8:31 pm #128627
Yeah, thanks for pointing it out. I’ve come across the WPML article, but didn’t check the language param in functions-enfold.
Currently it’s not working and it won’t be a conflict with any other plugin – this sticks to the ajax request.
Any chance this could be fixed in a next version of Enfold?
As a sidenote:
Just messing around with things I figured out how to do a work-around. I’ve been using Codestyling Localisation to do some wording corrections for the dutch language file provided by another Enfold user. No prob at all. I tried to work with the .mo files within WPML and switched now to the string translation handling. So if I do add the translations manually this way, it works. Weird stuff… :-/July 10, 2013 at 8:48 pm #128628
Moving on, I’m stuck with the title of the result form. This is done with
$output .= "<h4>".$post_type_obj[$key]->labels->name."</h4>";
The array is substituted with get_post_type_object() and at this point I’m lost in space. Does this belong to the standard language of WordPress? I do use de_DE and of course I do have the official nl_NL language files in the same folder.
I really don’t know why this ain’t working. Meanwhile I’ve set up a local Enfold copy without any plugins (except WPML), created some pages and it’s the same behaviour. Should I bother the folks at WPML with that?July 10, 2013 at 11:48 pm #128629
If I do a search on the dutch site and click on “View all results” the link is pointing to the main site. So I do have to manually add the $lang from the request, because I do use WPML with path setting (no subdomains). As for the primary language, the language setting must be removed.
So I changed in functions-enfold
$output .= "<a class='ajax_search_entry ajax_search_entry_view_all' href='".home_url('?' . $query )."'>".__('View all results','avia_framework')."</a>";
$lurl = $_REQUEST['lang'].'/';
if (empty($_REQUEST['lang']) || $_REQUEST['lang'] == 'de')
$lurl = '';
$output .= "<a class='ajax_search_entry ajax_search_entry_view_all' href='".home_url($lurl.'?' . $query )."'>".__('View all results','avia_framework')."</a>";
Not the best…July 14, 2013 at 11:30 am #128630
Ok, the main problem is that the __() function won’t work with the ajax call because you first need to load all textdomains of the current language first. It’s very strange that WPML can’t use the right textdomains out of the box and it’s probably a wordpress/WPML limitation. Maybe we can’t fully resolve this issue because of the limitations but I’ll ask Kriesi to look into it. For now I can only offer a solution to translate the “Portfolio Items” caption and to translate the “View all results” text. First revert the changes I posted before, then you need to use following function to add the lang parameter to the search
if(defined('ICL_SITEPRESS_VERSION') && defined('ICL_LANGUAGE_CODE'))
echo '<input type="hidden" id="lang" name="lang" value="'.ICL_LANGUAGE_CODE.'" />';
Then you can use following code in avia_ajax_search() to load the right textdomain
$lang = get_template_directory() . '/lang';
$unload = unload_textdomain('avia_framework');
$load = load_textdomain('avia_framework', $lang . '/'. get_locale() . '.mo');
and translate the “Portfolio Items” with
if($post_type == 'portfolio')
$output .= "<h4>"._x($post_type_obj[$key]->labels->name, 'post type general name','avia_framework')."</h4>";
$output .= "<h4>".$post_type_obj[$key]->labels->name."</h4>";
}July 15, 2013 at 4:18 pm #128631
To be perfectly honest, I am not sure what the best approach is, thats why I asked the WPML Team to give me some direction. If dudes approach works thats fine but it feels rather hackish so I am hoping for a cleaner solution and some hints by the plugin creators :)
Stay tuned!July 15, 2013 at 4:20 pm #128632
I’ll test it out and keep you informed (don’t close the thread right now, I do need some time)…July 15, 2013 at 6:24 pm #128633
Will keep it open in case the WPML Team wants to reply directly, since they have a forum account here as well :)
Just as a note: I checked their forum as well and the answers and solutions found there where similar to this one, so not sure if we can get an elegant solution here :/
The topic ‘Ajax Search – Translation handling probs…’ is closed to new replies.