cultureinfo

Custom Culture info in ASP.NET

大城市里の小女人 提交于 2019-12-11 15:15:15
问题 I created a CustomCulture class form CultureInfo. Here is my code: public class CustomCulture : CultureInfo { private string _parent; private string _name; private string _description; public CustomCulture(string parentCulture, string myCultureName) : base(parentCulture) { _parent = parentCulture; _name = myCultureName; _description = String.Format("custom culture({0})", _name); } public override string Name { get { return _parent + "-" + _name; } } public override CultureInfo Parent { get {

Defining the CultureInfo of a property using DataAnnotation

流过昼夜 提交于 2019-12-11 10:57:45
问题 I'm working on a MVC4 application where there's a field with a Data Mask like 000000,00 . Since the main culture of the project is pt-BR, this is correct and works as expected. The problem is that some of our developers have their cultures set to english, and when submitting this to a server set as en-US, a validation error occurs, because the method expects 000000.00 instead of 000000,00 . I thought about making a js fix to check the browser language and change the mask accordingly, but if

Difference between String.Compare and CultureInfo's CompareInfo

ぐ巨炮叔叔 提交于 2019-12-11 10:36:39
问题 I was trying my hand over System.Gloablization in a small desktop app. I am a bit confused about the additional control CultureInfo.Compare() has to offer than using String.Compare() method and its overloads. Let's say I have two strings String s1 = "\u3057\u3093\u304B\u3093\u305b\u3093"; //some Japanese text in Unicode String s2 = "\u30b7\u3043\u30ab\u30f3\u30bb\u30f3"; //Some Japanese text in Unicode CultureInfo ci = new CultureInfo("ja-JP"); String.Compare has several overloads, out of

Determine local culture of a PC without creating an application

落花浮王杯 提交于 2019-12-11 09:36:07
问题 Is there any way to determine the local culture of a PC (such as en-US) without running an application? I tried looking in Control Panel | Regional Settings (running WinXP), but I don't know how the choices there map to the PC's culture. I'm looking for a solution that doesn't require creating an .exe, such as running a command from the command prompt (not PowerShell), or a VbScript or JS file (as long as we are getting the real culture and not IE settings.) Thanks 回答1: To view the

C# WinForms DateTimePicker Custom Format

被刻印的时光 ゝ 提交于 2019-12-11 08:43:12
问题 I have a DateTimePicker on my form. I'd like part of the format to include "today", "tomorrow" etc as appropriate. I've got a simple implementation to work out the value (and there are much better ones here) but I'd like to take that implementation and put the value directly into the CustomFormat property of the DateTimePicker . For example, given the following format: dateTimePicker.CustomFormat = "dd MMM yyyy (YTT) HH:mm"; To produce the following display at runtime on 16th April 2011 at 12

Excel displays #Value! when regional setting changed to non-english

。_饼干妹妹 提交于 2019-12-11 08:00:04
问题 I just came cross an issue where Excel would display #Value! when regional setting was set to non-English format. (Control Panel-> Region and Language-> Pick Non-English Format from the list) It's fine if user selects English. All the UDF results will come through and get displayed correctly in the cells. It just wouldn't work for non-English ones. I have had a look at some of possible solutions online, like these ones: http://support.microsoft.com/kb/320369 http://msdn.microsoft.com/en-us

Are there cultures in which the decimal separator is longer than one character?

邮差的信 提交于 2019-12-11 07:55:23
问题 I must write a stringToNumber parsing function that can use custom strings for the following: decimal separator ( . for en-US => 3.1415 ) thousands separator ( , for en-US => 1,000,000 ) positive sign ( + for en-US => +5 ) negative sign ( - for en-US => -5 ) Can I assume that these are only one character (which would make the implementation easier) or are there any cultures in which any of these are longer? 来源: https://stackoverflow.com/questions/46538917/are-there-cultures-in-which-the

How is CultureInfo.CurrentCulture determined?

梦想与她 提交于 2019-12-11 06:52:44
问题 I have a computer in Israel. I deployed an MVC website to the computer's IIS. In this website I show the CultureInfo.CurrentCulture (for my needs) and it shows "he-IL". I changed: Control Panel > Region and Language > Formats to English (US) . Also I changed Control Panel > Region and Language > Administrative > System Locale to English (US) and of course restarted the computer. But CultureInfo.CurrentCulture still shows me "he-IL"! How can I change it without touching the code - only by

NumberGroupSizes for “en-IN” culture in windows server 2012 is wrong

岁酱吖の 提交于 2019-12-11 05:52:51
问题 NumberGroupSizes for "en-IN" culture is set as 3,2,0 which is wrong and ideally be set as 3,2 in windows server 2012. // Gets a NumberFormatInfo associated with the en-IN culture. NumberFormatInfo nfi = new CultureInfo("en-IN", false).NumberFormat; // Displays a value with the default separator ("."). Int64 myInt = 123456789012345; Console.WriteLine(myInt.ToString("N", nfi)); The above code ran on windows server 2012 gives out put as 1234567890,12,345.00 which is wrong. Ideally it should be

Globalization of CultureInfo & DateTimeFormatInfo: How can we change digits format to my language?

我的梦境 提交于 2019-12-11 05:49:23
问题 I use System.Globalization like below: CultureInfo calture = new CultureInfo(MyCultureInfoGoesHere); DateTimeFormatInfo info = calture.DateTimeFormat; info.AbbreviatedDayNames = new string[] { "bla", "bla", "bla", "bla", "bla", "bla", "bla" }; info.ShortestDayNames = new string[] { "bla", "bla", "bla", "bla", "bla", "bla", "bla" }; info.DayNames = new string[] { "bla", "bla", "bla", "bla", "bla", "bla", "bla" }; info.AbbreviatedMonthNames = new string[] { "bla", "bla", "bla", "bla", "bla",