Author Topic: Capture current url and update dynamically?  (Read 299 times)

0 Members and 1 Guest are viewing this topic.

Offline DSchraggTopic starter

  • Irregular
  • Posts: 8
    • View Profile
Capture current url and update dynamically?
« on: September 07, 2010, 07:09:40 PM »
I currently have Wordpress 3.1 running in network mode so that I could have 1 site but in 2 languages.

the url's are as follows:

http://mysite.com/ - English
http://mysite.com/fr - French

I want to have a link embedded in the template that will say either French or English and when clicked take the user to the same page they are viewing but in the other language. All my pages and articles on both sites will have the same permalinks, so what I want to have is a link that will grab the current url or page being viewed and add the fr into the link automatically, so that I never have to manually update these links.

Example:
When viewing Page 1 English, the href would automatically provide a link to Page 1 in French, and update itself dynamically as you viewed different pages..

mysite.com/page1 turns into mysite.com/fr/page1

Is this possible?

Thanks for everyones help.


Offline petroz

  • Enthusiast
  • Posts: 178
    • View Profile
Re: Capture current url and update dynamically?
« Reply #1 on: September 08, 2010, 12:46:17 AM »
I am not sure if this is the best approach, but setting the language in the user session/cookie, would be my approach.