Reputation: 2302
I'm working on multilingual Asp.NET MVC application. In url i need to use category name. Is there any way how to convert i.e japanese text to its url safe equivalent? Or should i use original text in url(www.example.com/製品/車 = www.example.com/product/car)?
EDIT: I need SEO firenly urls. I know how to strip diacritics and replace spaces(or other special characters) with '-'. But i wonder how to deal with foreign languages like Japanese, Russian etc.
Upvotes: 2
Views: 1146
Reputation: 941495
If you think a crawler could guess the product names or categories correctly to land on all pages of your site, it would be just as likely to do so with a number. Use the name or category ID, saves you the hassle from localizing these names as well.
Upvotes: 1
Reputation: 217293
You could UrlEncode the path elements, but the result will be illegible for the human eye (and probably search engines as well). Translating the elements to English or romanizing them sounds like a good idea. You need a dictionary though:
var comparer = StringComparer.Create(new CultureInfo("ja-JP"), false);
var dict = new Dictionary<string, string>(comparer)
{
{ "", "" },
{ "製品", "product" },
{ "車", "car" },
};
var path = "/製品/車";
var translatedPath = string.Join("/", path.Split('/').Select(s => dict[s]));
Upvotes: 0
Reputation: 1038810
It depends on how you are generating the url but you could use the UrlEncode method.
Upvotes: 2