Login | Forgot password | Register
What is OpenID?
OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.
With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.
For more information visit the official OpenID site.
Archive
SilverStripe Forums » Archive » Adding language code in front of URL segment - where ?
Our old forums are still available as a read-only archive.
|
Page:
1
|
Go to End | |
| Author | Topic: Adding language code in front of URL segment - where ? | 1582 Views |
-
Adding language code in front of URL segment - where ?

14 September 2008 at 7:36am
Good evening.
Can someone give me a hint at what part of the core the URL is constructed? What I want is to add currentLang() in front of the "ordinary" URI so that mysite.com/about-us/ becomes mysite.com/en/about-us/
I am staring at the Director and am tempted to add some Translatable::currentLang() here and there, but that baby is quite pasta-like to me. Is there a better, safer, place to find my happiness?
This is the last issue before I have my i18n with nice URLs and pretty links - help please !
Thanks!
-
Re: Adding language code in front of URL segment - where ?

15 September 2008 at 1:09pm
This line in your _config.php should get you started:
Director::addRules(2, array(
'$Lang/$URLSegment/$Action/$ID/$OtherID' => 'ModelAsController'
));Then you'll need to modify your .htaccess file so that the the $Lang bit gets changing into the lang query parameter before it gets sent to sapphire. Something like:
RewriteRule ^(\D+\/)(.*)$ sapphire/main.php?lang=$1&url=$2&%{QUERY_STRING} [L]
And then... maybe Director::setBaseURL($lang), but I'm not sure how to get the current language from the _config.php file. Maybe you'll need to create a custom controller to send requests to the right place. Also, it breaks the CSS and images..
Not sure where too from there, but maybe I gave you some ideas.
-
Re: Adding language code in front of URL segment - where ?

15 September 2008 at 4:59pm
Thanks, Hamish !
It is the part in your reply "And then ... maybe" where I am exactly. All else is fine already. I need to hack Director now, and maybe some other places to get my URLs right.
I'll go with trial and error now; I love it!
Thanks again!
-
Re: Adding language code in front of URL segment - where ?

15 October 2008 at 7:55pm
Hello!
Any results? A recipe to follow maybe? Any solution to solve the broken CSS and images path?
thanks a lot for your help.
-
Re: Adding language code in front of URL segment - where ?

20 October 2008 at 6:13am
I have solved my problems and wrote a recipe http://doc.silverstripe.com/doku.php?id=recipes:pretty_i18n_urls
Maybe it helps you get started.
-
Re: Adding language code in front of URL segment - where ?

27 November 2008 at 1:15am
Hi, I tried it, followed it exactly, but not sure what went wrong? this is my test site: http://kuholdings.com/demo/
Please help!! thank you so much!
| 1582 Views | ||
|
Page:
1
|
Go to Top |




