Developer forum

Forum » Development » Change link in template for every language

Change link in template for every language

Caro De Weze
Reply

Hi,

I want to add that my link will change if the website is in a different language. This is the piece of code I have already written:

@{
string GetProductPageUrl()
{
string currentLanguage = "en";
switch (currentLanguage)
{
case "en-001":
return "/products";
case "nl-BE":
return "/nl/producten";
case "en-US":
return "/english-usa/products";
case "fr-FR":
return "/fr/produits";
case "de-DE":
return "/de/produkte";
case "es-ES":
return "/es/productos";
default:
return "/products";
}
}
}

<a href="@GetProductPageUrl()" >@Translate("All products")</a>

I don't have much experience with this, so what else do I need to add or change to make it work?

Kind regards,
Caro De Weze


Replies

 
Kim Brøgger Hansen Dynamicweb Employee
Kim Brøgger Hansen
Reply
This post has been marked as an answer

Hi Caro,

You should use <a href="/Default.aspx?id=@GetPageIdByNavigationTag("Shop") "> instead.

/Kim

Votes for this answer: 1

 

You must be logged in to post in the forum