I can store all the values on the SQL database table (or is there other options?)
As the MVC default view engine is based on ASP.NET, you can utilize built-in localization support, i.e. resource files (or database providers), expressions (<%$ Resources:Strings, ...
%>) and methods, nicely wrapped in
localization helpers, or even better in
localization view engine.
Similarly, culture information is automagically working when enabled in web.config (<globalization culture="auto" uiCulture="auto" enableClientBasedCulture="true">), and you can use
action filter for some more advanced processing.
Additionally, the routing mechanism is flexible enough to allow language information to be present in the URL ("{lang}/Something/Else"), and you can implement localization code in a shared base controller class and/or action filter.
shapper
Contributor
3932 Points
3789 Posts
Localization in MVC
Apr 22, 2009 09:45 PM|LINK
Hello,
I am working on a MVC web site that needs to be in 3 languages.
So I need to localize the text on the views. For example:
I know I can store all the values on the SQL database table (or is there other options?)
My main problem is, however, how can I integrate the localization on the views ...
... I am not sure how and where should I use make this integration ...
Then of course I can create a Html.Localize helper or something like this ...
What is the best approach to do this?
Thanks,
Miguel
CW2
Participant
938 Points
207 Posts
Re: Localization in MVC
Apr 23, 2009 06:03 AM|LINK
As the MVC default view engine is based on ASP.NET, you can utilize built-in localization support, i.e. resource files (or database providers), expressions (<%$ Resources:Strings, ... %>) and methods, nicely wrapped in localization helpers, or even better in localization view engine.
Similarly, culture information is automagically working when enabled in web.config (<globalization culture="auto" uiCulture="auto" enableClientBasedCulture="true">), and you can use action filter for some more advanced processing.
Additionally, the routing mechanism is flexible enough to allow language information to be present in the URL ("{lang}/Something/Else"), and you can implement localization code in a shared base controller class and/or action filter.