views:

502

answers:

6

Should my controllers names be in my native language or in English? What is the current best practice? And if in English, how do I make sure that the urls stays in my native tongue?

I know that my webapp won't be multilingual and I rather not write a lot of boilerplate.

+1  A: 

You can write controller and controller's method names in any language (in UTF-8), that's not a problem. For a website which supports only 1 language that should be fine.

Koistya Navin
Should I do it though?
Daniel W
That isn't really true. URIs can only contain a certain, restricted subset of ASCII characters. So while you can write a controller name in any language, if you follow the convention that controller names appear in the URI, you have to use only names which can be expressed in Roman characters.
Craig Stuntz
+2  A: 

The convention in ASP.NET MVC is that controller and action names are the same as the controller and action in the URI except in special cases, like ambiguous overloads. I think it is a good idea to follow that convention, even if it means that the controller and action names will be in your native language and the rest of the code would be in English. If I were asked to debug a web site which displayed in some language I don't understand like Swahili, I would find it considerably easier to find the appropriate controller and action for a certain page if they reflected the Swahili URI than I would if it were translated into English.

Note, however, that most Unicode characters cannot appear in a URI (without Punycode). Only a restricted subset of ASCII characters can appear in the URI. See the specification for details.

Craig Stuntz
+1  A: 

It's your app so of course the choice is yours, but if you have native language URIs then I'd also go for native language controller & action names for consistency and ease of use for you.

Jeff Atwood wrote an interesting post on the topic of software development and the English language (not sure I agree but it is interesting and relevant). It won't answer your question but it's worth a read.

Steve Haigh
A: 

If you're going to have an international team look at your code then have English names. If you're going to work on it all by yourself, or have local people who speak languages then you can have names in your local languages.

Remember though, naming conventions are geared towards English and not for local languages. So that's a problem.

Cyril Gupta
+1  A: 

My opinion is maybe to try to load your routes definitions explicitly per language in your global.asax.

const string DEFAULT_LANGUAGE = "en";

routes.MapRoute("Product_EN", "en/Product/{action}", new { controller="Product", action="Index"} );

routes.MapRoute("Product_FR", "fr/Produit/{action}", new { controller="Product", action="Index"} );

routes.MapRoute("Product_ES", "es/Produto/{action}", new { controller="Product", action="Index"} );

route.MapRoute("Default", "{language}/{controller}/{action}/{id}", new { language = DEFAULT_LANGUAGE, controller="Home", action="Index", id=""});

Note: These are example, you should retreive the translated names from global resources.

But then we are forced to refer the correct route name in your views to use RouteActions. Anyway, it is a bit work-around solution but allows you to have translated URLs into your website like:

www.mysite.com/produit/afficher www.mysite.com/product/show ...

I hope it helps, Cheers

Fred.

A: 

From a SEO perspective i think its a good standard to use the same language on the controllers/views/actions that your MVC site is based on.

In my case i have a few sites based on my native language swedish, to get best search engine optimization and page ranking i'm using the same language when i name my controllers/views/action as the content language on the sites.

Inside controllers/views/actions I always use english as coding and commenting language.

I don't know if this is the best approach, but it feels like it is a good pattern to follow if you care about search engine optimization and page ranking.

QuBaR