Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This question was asked and answered here: <a href="https://stackoverflow.com/questions/5509965/globalization-in-asp-net-mvc-3">Globalization in ASP.Net MVC 3</a>. Not sure why the right answer (that community voted for 27 times) wasn't selected as correct one, but this is exactly the way to globalize / localize your ASP.NET MVC project.</p> <p>Copy paste:</p> <p>You localize it in the same way as any other application like this:</p> <ol> <li>Create a folder, call it e.g. Resources</li> <li>Right click the folder and add class... choose resource file. Call it anything you like e.g. Strings.resx</li> <li>Under the properties of file, change Custom Tool to be <code>PublicResXFileCodeGenerator</code></li> <li>Populate the Resource file with Translation key and value pairs (this will be the default translation)</li> <li>Create other resources with the name of the culture they're for in this format: {name}.de.resx e.g. Strings.de.resx</li> <li>(This is for Razor) crack open the web.config in the Views folder and add this to /configuration/system.web.webPages.razor/pages/namespaces: (assuming resources is the name of the folder you created the resources in and you haven't changed the default namespace on the resouce files themselves). This step means you don't have to fully qualify the resource classes in your views each time you want to reference a translation.</li> <li><p>Use the translations in place of text in your views like with the following code:</p> <pre><code>@Strings.MyString </code></pre></li> </ol> <p>Strings will be automatically translated in the view depending on CultureInfo.CurrentCulture but this is not set automatically for you</p> <p>You will need to change the <code>CurrentCulture</code> (potentially in <code>Application_BeginRequest</code>). How you do this is up to you, it could be a route value which sets it or you can read the user's browser language</p> <p>You can find a list of the user's prefered languages (in order) in <code>HttpContext.Current.Request.UserLanguages</code>.</p> <p>You need not to create a view per culture, you create view models with palceholders that will take their values from resources and you create resource (list of strings) per culture, rather than view per culture.</p> <p>Hope this will help you</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload