cultureinfo

ASP.NET MVC (Async) CurrentCulture is not shared between Controller and View

谁说胖子不能爱 提交于 2019-12-10 02:48:44
问题 I have an ASP.NET MVC 4 application that is targeting .NET Framework 4.7.1, with the problem that the culture is not shared between Controller and View, if the action contains async calls. I am referencing the NuGet package Microsoft.AspNet.Mvc 5.2.3 (and can be reproduced in 5.2.4). This is the code in the Controller: public class CulturesTestController : Controller { public async Task<ActionResult> Index(string value) { Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("fi-FI

ASP.NET Globalization: Culture=“auto” page directive with neutral culture crash?

旧巷老猫 提交于 2019-12-09 17:17:57
问题 I'm running into a case where an ASP.NET application using the built-in globalization facilities is crashing. On an ASP.NET page with the Culture="auto" directive, a user with a neutral culture as their browser language (such as "zh-Hans") will produce the following exception: Culture 'zh-Hans' is a neutral culture. It cannot be used in formatting and parsing and therefore cannot be set as the thread's current culture. at System.Globalization.CultureInfo.CheckNeutral(CultureInfo culture) at

How to determine if a CultureInfo instance supports Latin characters

巧了我就是萌 提交于 2019-12-08 17:20:51
问题 Is it possible to determine if the CultureInfo instance that I am working with is based on a Latin character set or not? 回答1: I believe you can use the CultureInfo.TextInfo.ANSICodePage . There are only so many of these (detailed here: http://msdn.microsoft.com/en-us/goglobal/bb964654). You mostly just need to check that it's value is either 1252 or 1250 回答2: Not sure whether this is sufficient, but how about testing the CultureInfo.NativeName property for Latin characters using the

Why is my CurrentCulture en-GB and my CurrentUICulture en-US

北慕城南 提交于 2019-12-08 16:35:28
问题 I have a C# application which has to run on machines with different culture settings. No problem I thought, it will just lookup on start up what the current culture is on the machine, and do everything for me. Well no, it would seam that something is not quite right. I have a Windows XP machine with everything in Regional and Language options set to English US, yet when my application starts up it reports that my CurrentCulture is en-GB and my CurrentUICulture is en-US . How can I get my

Persian Calendar not valid with CultureInfo

爱⌒轻易说出口 提交于 2019-12-08 16:31:19
问题 What's wrong with this code? Error(Exception) message : Not a valid calendar for the given culture. System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("fa-Ir"); //Error ci.DateTimeFormat.Calendar = new System.Globalization.PersianCalendar(); Application.CurrentCulture = ci; And what's its solution? Can I add a Calendar type to Windows XP regional option? 回答1: a dirty reflection-based workaround is here : http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread

Strange results from IndexOf on German string

我只是一个虾纸丫 提交于 2019-12-08 16:04:45
问题 I have string "Ärger,-Ökonom-i-Übermut-ẞ-ß" and when I run IndexOf("--") I get a result of 23. If I use Replace on same string nothing gets replaced. I don't understand what is happening, so can someone please shed some light on this issue? Application Culture is set on Croatian, it's not German, and framework version is 3.5. Changing culture to German (de-DE) doesn't change this strange behavior. Here is the screenshot from the debugger: 回答1: Since Mr Lister doesn't want his well deserved

how to handle time zones and dates in multi country/lingual application

梦想与她 提交于 2019-12-08 12:52:37
问题 I am currently working on a c# web application with a backend sql server database. I have some issues around dates that I need to work out. The application is hosted on web and database server in GMT time. The users are spread across 3 different time zones CEST, MSK, ALMT with the potential to have the site rolled out to other countries over time. In code at present I use DateTime.Now and GETDATE() in SQL, and with the location of the servers, this is GMT. My question is what form should the

Switching language (cultureinfo/globalization) does not affect ToolStripMenuItems

霸气de小男生 提交于 2019-12-08 12:18:20
问题 I have a Windows Forms application project, and on the main form I have a menu strip. Some place in this menu strip it is possible to select various languages. For example if the user selects "English", everything on this main form (and others in the future) should be turned into English language. I took this tutorial: click This works fine with labels and such, but it does not work at all with the tool strip menu items. They just stay with their default text. I tried to add two more lines to

Is there a way to get a flag image from a C# CultureInfo?

不羁的心 提交于 2019-12-08 10:02:58
问题 If I have a CultureInfo instance, is there any simple way — built-in, through a framework or via the OS — to obtain a matching "flag" icon matching that culture? This would avoid having to create a separate lookup. I couldn't find a member function to do the job in the documentation for CultureInfo, but perhaps there is some other not-too-taxing approach that involves other .NET classes that I haven't found. 回答1: No. There is no simple, built-in way, through the .NET framework or the Windows

Currency Culture Formatting not applying on DataGridView Column

风流意气都作罢 提交于 2019-12-08 02:27:19
问题 I have 2 DataGridViews (DGV), and in both I have currency columns which I want to format. The code I'm writing seems to work in one, but not in the other. Both the DGV's are set up this way: Data is first loaded into a DataTable. A BindingSource then links to this DataTable. And lastly the DGV's use this BindingSource object for their data. I use the following code in the form's Load event to customize both DGVs' currency columns: dataGridView.Columns[columnIndexHere].DefaultCellStyle