While scratching my head about why some Urls were coming out a bit weird when on a page with a translated version, I found out that there is some invalid parameter combinations being passed into the Friendly Url Provider API.
The above screenshot shows the parameters passed into the Friendly Url Provider via the DotNetNuke.Common.Globals.NavigateUrl (tab, path, pageName, portalSettings ) method overload. This particular call is for a Netherlands language translation of the current page, and is the linked Url for the nl-NL flag on the page.
In this example, this was the values provided: tab : tab object for TabId 61, tabPath of //TestPage path : ~/Default.aspx?tabid=63&language=nl-NL - the raw Url for the translated page, which is Tabid 63 page : /default.aspx (normal) portalSettings : current portal settings. You can see the current portal settings are for culture code en-US The problem is that the path (?tabid=63&language=nl-NL) don't match the supplied Tab object (tabid 61, culture= en-US). I think it shouldn't be valid to provide a path for one tab, and then provide the tab object for another.
I belive the problem lies in the TabController.GetTab(tabid,portalid, ignoreCache) call, which underlies the LanguageTokenReplace(newLanguage) call, via the NavigateUrl call. The problem is in this line (TabController.GetTab, line 703)
' if we have the PortalId then try to get the TabInfo object
If PortalController.GetPortalSettingAsBoolean("ContentLocalizationEnabled", PortalId, False) Then
tab = GetTabByCulture(TabId, PortalId, LocaleController.Instance().GetCurrentLocale(PortalId))
Else
tab = GetTabsByPortal(PortalId).WithTabId(TabId)
End If
Because the 'contentLocalizationEnabled' value returns True, then the tab is retrieved by the tabid, portalId and culture. However, because the current locale returned by 'GetCurrentLocale' is en-US, then the wrong tab is returned, which ends up in a mismatched tab object and path being sent to the Friendly Url Provider.
The fix is either to change the NavigateUrl call to find the Tabid based on the
Language parameter using GetTabByCulture when Language is supplied, or to
create a new overload for GetTab where the language can be supplied when checking for a contentLocalizationEnabled setting. For the purposes of language switching, you shouldn't rely on the current configured locale, because you want to find the Url for a different locale to the one you're currently in.
Let me know if this needs to be put in Gemini, or if anyone has any other thoughts. I don't think 5.5 should be released like this, because it will start to create legacy Urls for future upgrades that will be hard to fix up.