Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Setting locale via URL




3 June 2011 at 6:41pm Community Member, 25 Posts

Hey guys,

I am trying to figure out a way to make SilverStripe write the locale in the URL and also set the locale based on the URL. The idea is to have links such as or I am wondering what the best approach would be for this. The first problem is redirecting to the right locale based on the URL. I could either use a director rule and write a custom controller that extends ModelAsController or I could simply add a DataObjectDecorator to SiteTree and use Director redirects for that. What other options do I have?
The next step would be rewriting the links SilverStripe generates to include the locale. I also need to teach the static file publisher to create folders based on the locale and dump the files in there. Finally, I would need to tell SilverStripe to allow pages with the same name if they're in different languages. Is this even possible without core modifications?
The stuff I found so far deals with SilverStripe 2.2 or 2.3 and no longer works well with 2.4. I also use Translatable and having per-language nodes in the site tree isn't an option.