Forum Archive - replace the suffix by /?lang=fr

replace the suffix by /?lang=fr
Sep 26, 2014 2:10 pm by laurent
Hi, Right now gtranslate adds a language suffix (ex: /fr) at the end of the address line. However in the buddypress profile pages it comes before the name of the member. For example "mysite.com/fr/membername" I'm using gtranslate pro in conjunction with wpml which I need for specific parts of the website and I'd like to know if it would be possible to replace the actual suffix "/fr" by "/?lang=fr" and which always come at the end of the address line (also in buddypress pages)? I need it to work like that to be sure that when I move from a gtranslate page to another managed by wpml that I remain in the same logic. Is there a way to do it, even by customizing the gtranslate plugin? Thank you, Laurent.
Re: replace the suffix by /?lang=fr
Sep 26, 2014 8:50 pm by Edvard
Hi, You will need to modify gtranslate rewrite rules in .htaccess file and define which pages are going to be managed by gtranslate and which will not pass to it. Thank you!
Re: replace the suffix by /?lang=fr
Sep 29, 2014 9:31 am by laurent
Hi, I'm not exactly sure how to do it. Imagine I have "http://mysite/activity/?lang=fr" where I use gtranslate and I want to define that when I go to any other page on the site it should be "http://mysite/*/?lang=fr" Can you please tell me what I should put in htaccess? Thank you, L.
Re: replace the suffix by /?lang=fr
Sep 29, 2014 12:31 pm by Edvard
Hi, You are not using GTranslate on http://mysite/activity/?lang=fr, so may be you will define the problem more clearly, so I can try to find a solution for you. If you want mysite.com/fr/membername to become mysite.com/membername?lang=fr I can write a rewrite rule for you. However as I understand membername is not a constant, so you will need to write a rewrite rule per user, which of course wouldn't be possible. If you can configure it to be something like mysite.com/member/membername for your users, it will be easier to rewrite mysite.com/fr/member/* to mysite.com/member/*?lang=fr Thank you!
Re: replace the suffix by /?lang=fr
Sep 29, 2014 12:39 pm by laurent
Hi, I'm using gtranslate on all buddypress related pages, meaning: members, activity, groups, etc. While activity and groups are fix, it is correct that the member pages changes. So, as you write I need indeed to have for the profile pages: mysite.com/member/*?lang=fr and I also need it for the other pages: mysite.com/activity/?lang=fr and mysite.com/groups/?lang=fr Thanks a lot.
Re: replace the suffix by /?lang=fr
Sep 29, 2014 12:56 pm by Edvard
So, can you confirm that you want the following: 1. Redirect mysite.com/XX/member/* -> mysite.com/member/*?lang=XX 2. Redirect mysite.com/XX/activity/* -> mysite.com/activity/*?lang=XX 3. Redirect mysite.com/XX/groups/* -> mysite.com/groups/*?lang=XX Where XX is the 2 letter language code, for example fr, de, it, etc... Thank you!
Re: replace the suffix by /?lang=fr
Sep 29, 2014 1:08 pm by laurent
that's it.
Re: replace the suffix by /?lang=fr
Sep 29, 2014 1:16 pm by Edvard
Hi, Please place the following rewrite rules BEFORE gtranslate config rules in your .htaccess file: RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/member/(.*)$ /member/$2?lang=$1 [R=301,L,QSA] RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/activity/(.*)$ /activity/$2?lang=$1 [R=301,L,QSA] RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/groups/(.*)$ /groups/$2?lang=$1 [R=301,L,QSA] Thank you!
Re: replace the suffix by /?lang=fr
Sep 29, 2014 2:06 pm by laurent
Hi Edvard, It's working thanks a lot! If you don't mind, one last question. While now I manage to go from a french buddypress page to another page in french, the opposite doesn't work. Is their a way to say: mysite.com/*/?lang=xx -> mysite.com/member/member/?lang=xx ? Right now when I go from a non buddypress page in xx to the profile page it sends me to the default language rather than the same language I'm on.
Re: replace the suffix by /?lang=fr
Sep 29, 2014 4:47 pm by Edvard
Hi, It will be also possible using RewriteCond and RewriteRule statements in your .htaccess, however it is more time consuming. If you are ready to pay I can do that for you. Thank you!
Re: replace the suffix by /?lang=fr
Sep 30, 2014 11:56 am by laurent
Hi Edvard, Thank you for the offer. I'm actually that impressed with gtranslate that I want to use it for the whole website and replace wpml. I'm testing it now to see if that will be posible. This also means that I need to have ?lang=xx at the end of all pages. I tried using the same logic as before, but it doesn't work. This is what I use, can you please tell me what I'm doing wrong? # gtranslate config RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)/(.*)$ /$2?lang=$1 [R=301,L,QSA] RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)$ /$2?lang=$1 [R=301,L,QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/(.*)$ /gtranslate/translate.php?url=$2&lang=$1 [L,QSA] RewriteRule ^([a-z]{2}|zh-CN|zh-TW)$ /gtranslate/translate.php?lang=$1 [L,QSA] Thank you, L.
Re: replace the suffix by /?lang=fr
Sep 30, 2014 12:01 pm by Edvard
Hi, I think if you are not going to use wpml you will need to redirect domain.com/*?lang=xx to domain.com/xx/* , so you will have SEF URLs with GTranslate, is that correct or I'm missing something? Thanks!
Re: replace the suffix by /?lang=fr
Sep 30, 2014 12:23 pm by laurent
Hi, As I'm using multisite I have links going from one site to the other. Right now I have in my menus the following links: mysite.com/xx//mysite.com/page This of course doesn't work, therefore I need the language part to be added to the end of the url, that way I have as link: mysite.com/page/xx
Re: replace the suffix by /?lang=fr
Sep 30, 2014 12:36 pm by Edvard
I'm not sure I understand, may be you can write an example of what you have and what you want to get? Why you want to keep lang=xx parameter in the URL if you are not going to use WPML?
Re: replace the suffix by /?lang=fr
Sep 30, 2014 12:44 pm by laurent
I think the easiest is to show it to you. Please have a look at http://www.trainerswall.com/eshop/ If you click on the french flag you'll go to http://www.trainerswall.com/fr/eshop/ Now in the menu hover on "A Propos" and you will see the url link which sends us to another site within the multisite environment.
Re: replace the suffix by /?lang=fr
Sep 30, 2014 1:05 pm by Edvard
I can see you are using //www.trainerswall.com/services/ as a href attribute of <a> tag. You need to replace it with http://www.trainerswall.com/services/ or add class="nturl" attribute to the submenu item <a> tag, so it will not try to change the URL address and make it incorrect.
Re: replace the suffix by /?lang=fr
Oct 2, 2014 12:38 pm by laurent
It's indeed the easiest. thank you for your help.
Re: replace the suffix by /?lang=fr
Oct 2, 2014 3:04 pm by Edvard
You are welcome. Thanks!

SIMILAR TOPICS

Change language using a URL parameter: site.com?lang=DEJan 4, 2018 4:16 pmReplies: 4Post by: jivan
<html dir="ltr" lang="no" prefix="og: http://ogp.me/ns#">Dec 19, 2017 7:35 amReplies: 2Post by: besybuy
GTranslate conflict causing Error: format.replaceJul 29, 2014 10:36 amReplies: 7Post by: o0Corps0o
[CLOSED]translation of urls.How do i replace "%20" with "-"?Oct 15, 2015 12:21 amReplies: 2Post by: SIMTANDA
Why the URL has .html&lang=en&usg= in the endJul 3, 2015 1:45 amReplies: 1Post by: besybuy

Try GTranslate with a free 15 day trial