cultureinfo

CultureInfo issue with Modelbinding double in asp.net-mvc(2)

In my Jquery script I post two doubles using the browser's CultureInfo (en-UK) that uses the .as a fraction separator. My MVC app is running on a server with locale nl-BE using the , as a fraction separator. [AcceptVerbs(HttpVerbs.Post)] public JsonResult GetGridCell(double longitude, double latitude) { var cell = new GridCellViewMo...

Format exception messages using InvariantCulture or CurrentCulture?

When throwing exceptions, I often pass in a formatted string that exposes details about the problem that has occurred. I always specify a formatting provider if possible (which is good practice because otherwise you may forget to decide which culture is appropriate and as the default is the current culture, that can lead to many bugs). ...

How to Convert string (culture != "en-US") to int C# 2005

C# 2005, I have set the culture like below in Program.cs: CultureInfo myCulture = new CultureInfo("bn-IN");// like "en-US", "ja-JP" etc... Thread.CurrentThread.CurrentCulture = myCulture; Thread.CurrentThread.CurrentUICulture = myCulture; Application.CurrentCulture = myCulture; Then after opening the application I choose my keyboard, ...

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

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 stri...

Storing French (decimal values) in database?

Hi, I have my form set in french as well, and it automatically changes the text format to use ','. However When I try to insert my values into the database it says cannot convert nvarchar to decimal? Worst case, Is there a way I can disable the numbers from changing to use ',' and just use '.' always regardless what language it is? ...

Change Language in C#

I am developing a multilingual program in C# on Windows How to change Windows writing language on certain actions... e.g. to change from English to Arabic on focus event. Thanks ...

Changing CultureInfo of Main thread from worker thread

Is it possible to change CurrentUICulture of main thread when event is raised in worker thread? Code for ilustration: static void Main() { //do something Thread workerThread = new Thread(new ThreadStart(DoWork)); workerThread.Start(); //do something } void DoWork() { ConnectDatabase(); //do some work ChangeLangua...

CultureInfo thread safety

I have a multi-threaded application which parses some text and it needs to use English Culture Info for parsing numbers from this text. So, i do not want to create EngCulture everytime i call the parsing function. Currently i am passing EngCulture as a parameter but i am not happy with this. I want to define the EngCulture as a static me...

Date.js culture info is confusing me

I'm including date.js (from datejs.com) and the en-IE culture info script. If I call alert(Date.CultureInfo.dateElementOrder) I see the correct dmy, but if I try to interpret the date 02/03/01 I get 3 Jan 2001 and not 2 Feb 2001. I'm not sure whether this is a bug in date.js or a problem with me. ...

how to get all countries w/ corresponding RegionInfo.GeoId

As I've seen, not all countries are listed with CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures) If I look at the dialog below, I can see the missing countries are there. How can I get this complete list (with corresponding RegionInfo.GeoId) from .Net? ...

Display current time in this format: HH:mm:ss

Hi, I'm having some trouble displaying the time in this format: HH:mm:ss. No matter what i try, i never get it in that format. I want the time in the culture of the Netherlands which is "nl-NL". This was one of my (although i forgot to keep the count) 1000th try: CultureInfo ci = new CultureInfo("nl-NL"); string s = DateTime.Now.Tim...

Calling ASP.NET WebService with variant culture decimal

I am calling a webservice using jQuery. The called method has a parameter of type decimal. My site change culture based what user choices. Before call webservice I use CompareValidator to validate, it do the right job, considering ThreadCulture. I can use CompareValidator to convert my string to invariant at javascript? Because webse...

databinding list of double with invariant culture

I happen to have a list of double in a class and databind it to a combobox. The problem I am experiencing is that the displayed text for double has a comma instead of the dot. Ex 2,56 isntead of 2.56. The combo box seems to convert my doubles to string using the application culture I cannot just change the application culture to Invar...

CollectionViewSource and sorting (Danish alphabet)

Hello, I would like to sort some objects that have a Name property. These objects are stored in CollectionViewSource. I add sorting description in the following way: MyCollectionViewSource.View.SortDescriptions.Add(new SortDescription("Name"),direction)); where direction is Ascending/Descending. Everything works fine except one case...

Asp.net MVC 2 Localization Problem in dev

I work on a multi culture web project. I use Localize and Global Ressources(resx) as multilang technology. I work in team with 2 developer. How can we share .resx . When my teammate give me the 2 Files ( myfile.resx and myfile.Designer.cs) and I include it in my project, there is no way i can add some new string in the file. The new str...

.Net - CultureInfo: How to get country name

I used the code below to get the list of culture type, is their a way on how to get just the country name? Thank you static void Main(string[] args) { StringBuilder sb = new StringBuilder(); foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { sb.Appen...

ASP.NET reset thread culture after use?

If I set Thread Culture and UICulture for one ASPX, after pass for that page, all my aspx that use the same thread(not same request) will have the same Culture? Because I need to set Culture just for one ASMX ...

How do I tell my webpage to use a specific UI Culture?

I can tell my page to use a certain CultureInfo like System.Globalization.CultureInfo.CreateSpecificCulture("en-US"); The code above only set's the CultureInfo, not the UICulture, how can I tell the Page to bypass what the browser says and use a specific one, so all GlobalResource's could be applied to the correct culture? in the cod...

CultureInfo.NumberFormat Hide Comma

I am trying to create a NumberFormat that will not use Groups at all. I would like all numbers to be displayed with NO commas. Example: 1999 instead of 1,999 2000000 instead of 2,000,000 etc... Unfortunately, I am using a 3rd Party control that is a NumericEditor and it applies a CultureInfo setting on it to show commas. So I ne...

Cultureinfo mismatch caused Excel Automation to fail

I am using interop to open Excel files in C#. The current problem I have is that, if the Excel I installed is English, for the opening to work, I have to set LocalSettings to English. It will fail these two do not match. I found that this is an known issue http://support.microsoft.com/kb/320369. However, I could not always set the thre...