globalization

MVC Localization of Default Model Binder

早过忘川 提交于 2019-11-30 14:36:32
I am currently trying to figure out how to localize the error messages generated by MVC. Let me use the default model binder as an example, so I can explain the problem. Assuming I have a form, where a user enters thier age. The user then enters "ten" in to the form, but instead of getting the expected error of "Age must be beween 18 and 25." the message "The value 'ten' is not valid for Age." is displayed. The entity's age property is defined below: [Range(18, 25, ErrorMessageResourceType = typeof (Errors), ErrorMessageResourceName = "Age", ErrorMessage = "Range_ErrorMessage")] public int Age

Set uiCulture automatically based on browser accept language

谁都会走 提交于 2019-11-30 14:00:25
问题 How I can set the culture of the ui automatically based on the users'browser? All I found about this is Globalize.culture("pt-BR"); But it sets pt-BR as default and I dont want set this by default! I want only set this if the user is pt-BR! How can I do this? And the validator methods, how can I set them for a specific culture? 回答1: In a ASP.NET MVC the web.config is the right place. There is a quick summary, the first snippet shows, how could be e.g. pt-BR culture forced <globalization

Multiple Languages(English, French) on ASP.NET Page

╄→гoц情女王★ 提交于 2019-11-30 13:28:01
I was just wondering what is the best way to handle multiple languages on a web page? Should I create an event in the load where I change the labels of all my controls to the approrpiate language text, or is there a better way? I am using .NET framework, thanks. For ASP.NET, use Resource files. This will let you provide multilingual functionality and you can add translations without needing to recompile. http://www.beansoftware.com/ASP.NET-Tutorials/Globalisation-Multilingual-CultureInfo.aspx You will want to look at the section of the MSDN documentation that deals with localization and

List of all available languages for Windows .NET framework

ε祈祈猫儿з 提交于 2019-11-30 09:50:57
I've been searching for the answer over the net, but I don't seem to be able to find a comprehensive list of all languages available for my app with their exact display name. (I find many lists, but none of them seem to match the language strings I have. Read on.) The closest one I found is this one, but is not complete. I am coding a plugin in C# where the text is exported from SDL Trados Studio to Word and the language is set accordingly in Word. I need to write a custom method that casts these language names to their relevant Word.Language equivalent. This is because Trados (using the

ASP.NET application doesn't reflect Regional settings

邮差的信 提交于 2019-11-30 09:29:18
问题 I've set, in my regional settings (for Czech, culture cs-CZ), the short time / long time pattern to following: Short time: H.mm Long time: H.mm.ss I'm trying to use those settings in C# applications. In following console app, everything works: using System; using System.Globalization; class Program { static void Main() { Console.WriteLine(CultureInfo.CurrentCulture.Name); Console.WriteLine(CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern); Console.ReadLine(); } } The output is, as I

ASP.NET MVC 3 : - Using database instead of resource files as the localization store

廉价感情. 提交于 2019-11-30 09:23:42
We have localised strings in the database and would like to know if extending the ASP.NET Resource Provider Model would work with the ASP.NET MVC 3 Razor view engine. Kindly let me know if ASP.NET MVC 3 Razor view engine supports retrieving localized strings from the database once we have extended the ASP.NET Resource Provider model. Or does it work only with Classic ASP.NET and not with ASP.NET MVC. Thank you Satyaprakash J The cleanest solution I've found so far is: http://www.codeproject.com/Tips/514321/A-Simple-and-Effective-Way-to-Localize-ASP-Net-MVC . Comments/Feedback are welcomed.

Should Exception Messages be Globalized

白昼怎懂夜的黑 提交于 2019-11-30 09:16:42
I'm working on a project and I'm just starting to do all the work necessary to globalize the application. One thing that comes up quite often is whether to globalize the exception messages, but ensuring that string.Format uses CultureInfo.CurrentCulture instead of CultureInfo.InvariantCulture. Additionally this would mean that exception messages would be stored in resource files that can be marked as culture-specific. So the question is, should exception messages be globalized or should be be left in either the InvariantCulture or the author's country; in my case en-US. Jon Skeet Exception

When should I specify CurrentCulture or InvariantCulture and when should I leave it unspecified?

末鹿安然 提交于 2019-11-30 08:12:59
What is the best practice for specifying CurrentCulture or InvariantCulture and not specifying the culture at all? From what I have read, if you're doing serialization, for instance, you need InvariantCulture as a means of specifying a canonical representation of a data value. That's a relatively small percentage of culture-based string manipulations. I find it long, verbose, and ugly most of the time to specify it every time I do, say: var greeting = string.Format(CultureInfo.CurrentCulture, "Hello ", userName); However, my team recently turned FxCop on and now there's a push to always use

How to set collation for a connection in SQL Server?

允我心安 提交于 2019-11-30 08:11:40
问题 How can i set the collation SQL Server will use for the duration of that connection? Not until i connect to SQL Server do i know what collation i want to use. e.g. a browser with language fr-IT has connected to the web-site. Any queries i run on that connection i want to follow the French language, Italy variant collation. i envision a hypothetical connection level property, simlar to SET ANSI_NULLS OFF , but for collation 1 : SET COLLATION_ORDER 'French_CI_AS' SELECT TOP 100 FROM Orders

How to set culture for date binding in Asp.Net Core?

大憨熊 提交于 2019-11-30 08:05:17
问题 I have an Asp.Net Core application with MVC. I'm submitting a form with a date on the form. Form looks (roughly) like this: @model EditCustomerViewModel <form asp-action="Edit"> <input asp-for="ServiceStartDate" class="form-control" type="date" /> <input type="submit" value="Update" class="btn btn-success" /> </form> Controller action is: [HttpPost] public async Task<IActionResult> Edit(EditCustomerViewModel viewModel) { // do stuff return RedirectToAction("Index"); } View model is: public