जैसा कि पहले सुझाव दिया गया है, यह सम्मेलन से निकलता है जहां वेबसाइट यूआरएल (और मार्ग) अंग्रेजी का उपयोग करती है।
फिर भी, यह संभव है, लेकिन ऐसा करने के लिए, आपको शायद हर विदेशी भाषा के लिए प्रति मार्ग एक मार्ग उत्पन्न करना होगा। तो 20 कार्यों और तीन भाषाओं (अंग्रेजी, फ्रेंच, और जर्मन) वाली वेबसाइट के लिए, आपको 41 मार्ग (20 फ्रेंच, 20 जर्मन और 1 अंग्रेजी) की आवश्यकता होगी। सबसे कुशल प्रणाली नहीं, मैं मानता हूं, लेकिन यह काम करता है जैसा आप चाहते हैं।
//You'll only need one of these, which is the default.
routes.MapRoute(
"English route",
"en/{controller}/{action}/{id}"
new { controller = "Home", action = "Index", language = "en" },
);
routes.MapRoute(
"FrenchHome",
"fr/Demarrer/Index/{id}",
new { controller = "Home", action = "Index", language = "fr" }
);
routes.MapRoute(
"GermanHome",
"de/Heim/Index/{id}", //'Heim' is, I believe the correct usage of Home in German.
new { controller = "Home", action = "Index", language = "de" }
);
//Some more routes...
routes.MapRoute(
"FrenchSoftware",
"fr/Produit/Logiciels/{id}",
new { controller = "Product", action = "Software", language = "fr" }
);
routes.MapRoute(
"GermanSoftware",
"de/Produkt/Software/{id}", //In this instance, Software should be the same in German and English.
new { controller = "Product", action = "Software", language = "de" }
);
//And finally, the 404 action.
routes.MapRoute(
"Catchall",
"{language}/{*catchall}",
new { controller = "Home", action = "PageNotFound", language = "en" },
new { language = "^(en|fr|de)$" }
);
//This is for the folks who didn't put a language in their url.
routes.MapRoute(
"Catchall",
"{*catchall}",
new { controller = "Home", action = "PageNotFound", language = "en" }
);
अपने कार्यों में, उदाहरण के उत्पाद/सॉफ्टवेयर के लिए ...
public ActionResult Software(string language, int id)
{
//This would go off to the DAL and get the content in whatever language you want.
ProductModel model = ProductService.GetSoftware(language, id);
return View(model);
}
मैं करूंगा लव यह कि कोई साथ आया था और कहा ऐसा करने का एक बेहतर तरीका है कि वहाँ है, क्योंकि मैं इस बात से सहमत कि एक विदेशी भाषा में यूआरएल अच्छा नहीं है, और यह देखते हुए कि इंटरनेट स्वयं यूआरएल में गैर-रोमन पात्रों को अनुमति देने की ओर बढ़ रहा है, जितनी जल्दी हम इसके समाधान को बेहतर मानेंगे।
केवल इतना ही नहीं, लेकिन मुझे गर्व है कि फ्रांसीसी लोग अपनी वेबसाइट यूआरएल को अंग्रेजी में देखना पसंद नहीं करते हैं। :)
असल में यह बहुत अच्छा विचार नहीं है कि आप खोज इंजन रैंकिंग के बारे में चिंतित हैं। आप हमेशा अंग्रेजी पृष्ठ पर रीडायरेक्ट कर सकते हैं या एक ही इकाई के सभी उदाहरणों के लिए मानक कैननिकल यूआरएल का उपयोग कर सकते हैं। –