I have a requirement where my URL should be in format : http://domain/de-DE/pagename
I have following settings done for my site:
<setting name="Languages.AlwaysStripLanguage">
<patch:attribute name="value">true</patch:attribute>
For Link Manger Provider i have following properties set:
languageEmbedding="always"
addAspxExtension="false"
alwaysIncludeServerUrl="false"
encodeNames="true"
languageEmbedding="always"
languageLocation="filePath"
lowercaseUrls="true"
shortenUrls="false"
useDisplayName="false"
Now the issue is, when I am giving internal link in general link for a page say, I am on page http://domain/de-DE/page1 and I have a navigation on which general link field has link of page2.
The expected url is http://domain/de-DE/page2 on navigation link
But I am getting URL as http://domain/de/DE/page2 which is redirecting me to 404 page.
I am fetching the link from general link field using method shown below:
public static string LinkFieldurl(this Item item, ID fieldID)
{
if (item == null)
{
return string.Empty;
}
if (ID.IsNullOrEmpty(fieldID))
{
throw new ArgumentNullException(nameof(fieldID));
}
var field = item.Fields[fieldID];
if (field == null)
{
return string.Empty;
}
var linkUrl = new LinkUrl();
return linkUrl.GetUrl(item, fieldID.ToString());
}
Now this is returning me URL with wrong format of language embedded in URL.
Please suggest me some way in which i can get correct format of language(de-DE) or if I am going somewhere wrong?