slug translation implemented, needs review

Any suggestions on how to improve qTranslate? Post here!

Re: slug translation implemented, needs review

Postby baga » Fri Jan 20, 2012 9:51 am

Hello I noticed a problem with the tag <link rel="alternate", for example I have this page, in English and Italian:

mysite.com/page-one/
mysite.com/it/pagina-uno/

The alternate link for the Italian page on the English version is:

Code: Select all
<link hreflang="it" href="http://mysite.com/it/page-one" rel="alternate" rev="alternate" />


The correct tag should be:

Code: Select all
<link hreflang="it" href="http://mysite.com/it/pagina-uno" rel="alternate" rev="alternate" />


Anyone knows how to fix this issue?
baga
 
Posts: 14
Joined: Sat Apr 03, 2010 1:07 pm

Re: slug translation implemented, needs review

Postby miamia » Tue Jan 24, 2012 5:12 pm

hello,

I tried to use Google XML Sitemaps with qTranslate Support and slug together but in my xml are not translated urls (when I browse my web links are ok, problem is in xml only).
Example from xml:
en/welcome
de/welcome -> but it should be de/hallo

Where is problem?

my wp 3.3.1
XML Sitemap Generator for WordPress 3.2.6.2
qtranslate 2.5.27
qTranslate slug with Widget 0.5
miamia
 
Posts: 1
Joined: Tue Jan 24, 2012 5:09 pm

Re: slug translation implemented, needs review

Postby fachtopia » Fri Jan 27, 2012 5:15 pm

How can I implement this plugin ? HOWTO and where to dowload it
fachtopia
 
Posts: 1
Joined: Fri Jan 27, 2012 5:00 pm

Re: slug translation implemented, needs review

Postby adriavidal » Tue Feb 14, 2012 9:38 am

site.com/es/paginaES OK

site.com/en/pageEN fail!!!


I've found these error at error_log,
as i'm writing the page in spanish the post_name where fails


Error Illegal mix of collations for operation 'UNION' de la base de datos de WordPress para la consulta (SELECT ID, qts_slug AS post_name, post_parent
FROM wp_posts, wp_qtranslate_slug
WHERE 'who-we-are' = qts_slug
AND 2 = qts_type
AND 'en' = qts_lang
AND qts_id = ID)
UNION (SELECT ID, post_name, post_parent
FROM wp_posts
WHERE post_name = 'who-we-are' AND (post_type = 'page' OR post_type = 'attachment')) realizada por require, wp, WP->main, WP->parse_request, apply_filters, call_user_func_array, qTranslateSlug_filter_request, qTranslateSlug_get_page_by_path


could the las where search for the id written at the wp_qtranslate_slug and not the post_name ?

will try it for my self and post if find a solution.
adriavidal
 
Posts: 2
Joined: Tue Feb 14, 2012 9:31 am

Re: slug translation implemented, needs review

Postby adriavidal » Tue Feb 14, 2012 10:42 am

got some little hack and now is running, sorry
if it's a ugly hack

at

qtranslate-slug-with-widget at line 715

$query = $wpdb->prepare(
" SELECT ID, post_name,post_parent
FROM wp_posts
WHERE ID = (SELECT qts_id
FROM wp_qtranslate_slug
WHERE %s = qts_slug AND qts_type=2)
AND (post_type = 'page' OR post_type = 'attachment')",
$leaf_path, QTS_PAGE, $lang, $leaf_path );
$pages = $wpdb->get_results($query);

//$fb && fb($query, 'pages query') && fb($pages, '$pages');
adriavidal
 
Posts: 2
Joined: Tue Feb 14, 2012 9:31 am

Re: slug translation implemented, needs review

Postby iklajo » Thu Mar 08, 2012 3:35 pm

Hello
I have the same problem with the translated slug being wrong in the links. I have three languages, Croatian, English and German. I've created a text page to see if the language switcher is working fine. The links should be like the following

/kontakt-hr
/en/contact-us
/de/contact-de

If I'm on the croatian version of the page, the language switcher gives me the following links

/kontakt-hr THIS IS OK
/en/kontakt-hr THIS IS WRONG
/de/kontakt-hr THIS IS WRONG

As you, who have the same problem, have noticed this is not good. If you are on your homepage and switch here to english for example, then you'll get the right url for the active language for the contact page, in both the mai nmenu and the language switcher. The url in your main menu is the way it should be but in the language switcher it's correct only for the active language.

English version of the page
/contact-us THIS IS WRONG
/en/contact-us THIS IS OK
/de/contact-us THIS IS WRONG

I'm not an expert, but it seems like the language switcher doesn't get the right slugs for the inactive languages. Once you've set a language and browse the website through the main menu, things look fine, only the language switcher make problems when you wanna switch from one to an other language.
iklajo
 
Posts: 2
Joined: Thu Mar 08, 2012 3:19 pm

Re: slug translation implemented, needs review

Postby ilpiac » Thu Mar 08, 2012 7:59 pm

iklajo, I had more or less the same problem and I solved it this way.
First, I'm not a programmer, I know something about PHP but I'm a graphic designer and - funny - I like designing more for offline projects than online ones :)
But now I'm working on a website project, probono, so I have a very low budget - in fact no budget at all - and I have to use free solutions or to find solutions by myself.

Well, the problem for me was more or less the same: language switcher's links were ok for pages and single posts, but wrong for category pages with listing of posts.
I use a personal language switcher, I wrote the code by myself but I also tested the standard language switcher and the problem was the same.
My link were ok for slugs translation but wrong for language code. For instance, the italian page for category "notizie" had this language switcher's links:
IT > .../it/category/notizie
FR > .../it/category/informations
EN > ...(it/category/news

I was using this fix: http://en.codatavern.com/qtranslate-slu ... in-fix/but the problem was still there for category pages...
I continued to use the fixed version of code, but I started to check the code - both qTranslate Slug and Wordpress - and I found that the problem was this.
In taxonomy.php at a certain point there is the definition of get_term_link function.
The last line of code for get_term_link function is this one:
Code: Select all
return apply_filters('term_link', $termlink, $term, $taxonomy);

This line makes everything going wrong.
qTranslate in fact adds a filter for term_link so that the last line of code of the get_term_link function uses the function defined in qTranslate.
But this function doesn't care for language code, so everything is set equal to actual language: IT, in my case.

So I decided to add two lines of code. First, find this code:
Code: Select all
//Activates filters defined by this module
add_filter('page_link',         'qTranslateSlug_page_link', 0, 2);
add_filter('post_link',         'qTranslateSlug_post_link', 0, 3);
add_filter('category_link',      'qTranslateSlug_category_link', 0, 2);
add_filter('tag_link',         'qTranslateSlug_tag_link');
//add_filter('the_permalink',          'qTranslateSlug_convertURL', 0, 4);

And add this line:
Code: Select all
add_filter('term_link',      'qTranslateSlug_category_link', 0, 2);

I know that I would have to write an ad hoc function (i.e. qTranslateSlug_term_link ) and add that as a filter, but adding qTranslateSlug_category_link works fine for me so it's ok. If any real - not a fake like me :) - programmer wants to write a more efficient code, he's welcome!

The second step is to add a line of code inside qTranslateSlug_remove_qtrans_filters because if you add a filter for qTranslateSlug you have to remove the corresponding filter set by qTranslate.
So inside this function you add this line of code:
Code: Select all
remove_filter('term_link', 'qtrans_convertURL');


You're done!

This worked for me, I hope it works for you too.
Or perhaps this is a hint for a better solution.

I also solved a problem with searched results pages because they were ok only for IT pages but not for for EN e FR.
I write the solution for this too, just in case someone else would have the same problem.
Why this problem? Because the link set by the search form was like this:
Code: Select all
.../it?s=example
where example is the searched word.
This code works for the main language, but it fails for other languages because they translate to this:
Code: Select all
.../fr?s=example

Code: Select all
.../en?s=example

They need a slash after the language code to work, like this:
Code: Select all
.../fr/?s=example

Code: Select all
.../en/?s=example


So also the IT URL must have the slash, like this
Code: Select all
.../it/?s=example

to have the correct translation.

I added the slash in my template search form code and everything is ok.
Sometimes problems can occur because of template code too :(
Not that the template is wrong by itself, but it doesn't work with slug plugin if you don't add the slash :)

Now I still have a little problem with category pages because I can see post listed only when I'm on IT page (my default language) and not on FR and EN pages, but I will further investigate because I think this is another kind of problem 8-)

maurizio
ilpiac
 
Posts: 2
Joined: Tue Mar 06, 2012 7:31 pm

Re: slug translation implemented, needs review

Postby iklajo » Fri Mar 09, 2012 11:35 am

Thanks for your answer. Things work now fine for things I'm using on the website. :D
iklajo
 
Posts: 2
Joined: Thu Mar 08, 2012 3:19 pm

Re: slug translation implemented, needs review

Postby aleguasp75 » Sat Mar 24, 2012 2:09 pm

I can't solve the problem of not translated slugs in qtranslate installed site . Is there somebody who can help me with "step by step" precise instructions? I'm not a programmer . I will be grateful for life :D
aleguasp75
 
Posts: 6
Joined: Fri Jul 22, 2011 11:29 am

Re: slug translation implemented, needs review

Postby CarlosSanz » Mon May 28, 2012 7:41 pm

Hi all,

a few days ago, i uploaded my Qtranslate Slug plugin 0.9 (fork of Cimatty Consulting plugin in 2010) to Wordpress repository. This plugin works, but the code has one year old and because is an adaptation it's quite dirty. Now i'm involved on developing a new version 1.0, completely refactored with OOP, and some improvements and fixes. This new version is almost finished and i hope update the plugin as son as possible.

Anyway for anyone who wants a solution for taxonomies and post types, version 0.9 could be useful:

http://wordpress.org/extend/plugins/qtranslate-slug/

Best regards.
C
Last edited by CarlosSanz on Tue Jun 05, 2012 5:56 pm, edited 4 times in total.
CarlosSanz
 
Posts: 8
Joined: Tue Feb 22, 2011 1:23 am

PreviousNext

Return to qTranslate Suggestions Forum

Who is online

Users browsing this forum: No registered users and 1 guest