it'll have loaded that fluentstate somehow, I'd recommend checking out how that object gets created and passed around (starts in the middleware IIRC)
Mmmm, I was hoping to find something like
getLocaleURLPrefix() similar to
getAction() that'd return the locale portion from the current url else null or false if it doesn't exist. It looks like routing rules are generated and inserted for each locale. There's multiple ways to get the current locale, whether it's set in the url or not, but it seems to reliably retrieve the locale prefix from a url doesn't exist as an existing method on any class which I've seen.
I've created this small method to detect whether a locale prefix exists in the url, then to redirect if it doesn't exist, but a default locale does exist.
$this->getRequest()->getURL() may not contain the locale prefix, but
$this->Link() most often does contain the appropriate locale prefix which I'm assuming gets generated after routing rules are processed. Quite handy.
@taoceanz you're right there's no one place you can get that prefix; However you can copy the code from FluentSiteTreeExtension::updateRelativeLink() to get that
disable_default_prefix is important for calculating the prefix 😉
Thanks for the suggestions @tractorcow
@Sherry has joined the channel
Is there a way to force the default locale? On our site, en_US is default, but in a new browser it consistently loads in Chinese.
detect_locale interfere with the routing and locale detection by setting a higher precedence on the detected locale over the "default" locale?
@taoceanz it'll run from the
accepts header (or whatever it is).