I need to extend Silverstripe to set the locale within the URL: e.g. /language-country/pagename
The following code is just a quick implementation but it works for nowâ€¦
1. First I had to add a new controller for extending the "ModelAsController" to handle the changed URL syntax:
2. Add a rule for calling the new controller within _config.php:
3. Rewrite the link targets (now with locale) within Page.php:
4. To allow setting the same page name in translated pages, I had to uncomment some lines within the core (SiteTree.php), which is definitely not the way it should be done. So if there are any new ideas please let me know!
It took a while to figure out that Versioned::reading_stage is not set when I use my "TranslatedModelAsController" -- if I use "ModelAsController" everything works as expected --therefore I added some lines with a small hack I found in the Silverstripe forums: TranslatedModelAsController > Line 17-22
Any improvements and comments are welcome!