4

I am using qtranslate plugin for my WordPress site to make it a multi-language site.

Now I have got a requirement like

For English the url should look like www.sitename.com/contact-en For French the url should look like www.sitename.com/fr/contact-fr

How can I accomplish this? (qTranslate is the plugin used)

Note: There should not be any post id coming in-between

As per the post in https://wordpress.stackexchange.com/questions/24061/multilingual-permalinks-qtranslate I tried http://www.3dolab.net/en/qtranslateslug-plugin-widget but 'page not found' errors are occurring. It looks like the author has stopped improving that plugin as per the 29th comment in that page.

1
  • I'm facing exactly the same issue so I am very interested in this solution. Unfortunately, I am far from being an expert in php and therefore I did not manage to make it work for me. Could you please provide a bit more details of your piece of code. Tx in advance.
    – user10542
    Nov 24, 2011 at 0:20

3 Answers 3

0

In qTranslate settings in admin panel open advanced options and check the radio button for using language prefixes after domain name. I assume you have French listed in Languages settings of the plugin correct. You may expect dates shown incorrectly after that, use php date function to fix that in your particular language settings (edit language). Like j F. See primer at minexrussia.com/2011 where ru prefix is placed the same way. To avoid en prefix, select english as default language and check setting in Advanced options for not to show prefix for default language. I suggest removing all other languages except en and fr in plugin settings.

1
  • Yes I do have French in my language list. Date should not come in the url. My basic requirement is that I want the slug to be able to be given for different languages. For example: /contact-en for English, /contact-fr for French as described in my question.
    – Beniston
    Nov 16, 2011 at 3:49
0

Please have a look at http://wordpress.org/plugins/qtranslate-slug/

Qtranslate is a nice plugin but unfortunately today is outdated. Qtranslate Slug is an addon to QTranslate, which adds support for permalinks translations and fix some QTranslate deficiencies since wordpress 3.0.

0

Having the "qtranslateslug-plugin-widget" plugin working in the admin side to store slugs in the slug table, I have put my own code in the user side.

In the wp-blog-header.php page I have added my own code just before the inclusion of wp-load.php file. I took the url from $_SERVER['REQUEST_URI'], and using the slug and language in it, retrieved the post name and assigned the modified URI to $_SERVER['REQUEST_URI'] appropriately.

For example:

Before I edit: $_SERVER['REQUEST_URI'] = '/fr/french-slug';

After I edit: $_SERVER['REQUEST_URI'] = '/post-name';

Let me explain it in a little more detailed way

  1. Assign $_SERVER['REQUEST_URI'] to a variable

  2. Get the slug exploding it with slash (/)

  3. Check the slug in the slug database table which "qtranslateslug-plugin-widget" plugin is using and get the post id from there

  4. Now using the post id get the post name from the post table.

  5. Implode it in such a way as I have shown in the above example.

  6. Assign it back to $_SERVER['REQUEST_URI']

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.