culture

How to getting browser current locale preference using javascript?

Does anyone know how to obtain the browser culture from firefox and google chrome using javascript? Note: This is an asp.net 3.5 web application. The requirement is to try and set the applications display culture based on the browser culture. I have found very few bits and pieces of information for the other browsers but they do not ...

C#: how to explicitly set culture for Double.Parse(string num)

I download one program that read file and then parse double values from String to Double. But I get an exception because this file contains numbers with '.' separator, but there is ',' in my culture. How can I set culture explicitly? ...

C# float.tryparse for French Culture

I have a user input which can contain float values ranging from : 3.06 OR 3,06 The culture we are in is French and thus when the user inputs 3.06 and I run a float.tryParse over this value it does not get converted to 3.06 into a new variable (type float) // inputUsedAmount.Value from UI is : 3.06 float usedAmount = 0.0f; float.TryPars...

case insenstive string replace that correctly works with ligatures like "ß" <=> "ss"

I have build a litte asp.net form that searches for something and displays the results. I want to highlight the search string within the search results. Example: Query: "p" Results: a<b>p</b>ple, banana, <b>p</b>lum The code that I have goes like this: public static string HighlightSubstring(string text, string substring) { var inde...

Problem comparing French character Î

When comparing "Île" and "Ile", C# does not consider these to be to be the same. string.Equals("Île", "Ile", StringComparison.InvariantCultureIgnoreCase) For all other accented characters I have come across the comparison works fine. Is there another comparison function I should use? ...

How to compare characters (respecting a culture)

For my answer in this question I have to compare two characters. I thought that the normal char.CompareTo() method would allow me to specify a CultureInfo, but that's not the case. So my question is: How can I compare two characters and specify a CultureInfo for the comparison? ...

Using telerik radGrid - how to set the Date format for autogenerated column in edit mode

Hello All, Using VS2008, and Telerik radGrid version 2010.1.519.35 I have a about 50 DNN modules using telerik radgrid and I need to display my dates in dd/mm/yy format. It is possible to do this easily in view mode, but when I switch to edit mode, it is more of a struggle. I can write a snippit of code to reformat the displayed date...

Parsing French Date

I am trying to parse a french date to a DateTime object with no luck so far. Is there a way? to do that. String foo = "mar, 20 avr 2010 09:00:00 -0500"; I've Already tried parsing with a different culture and changing the culture of the thread. System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA",true); Cult...

what does setting the current thread's culture code do?

what is the result of setting the current thread's culture code? I understand if I use the resource file it will pull label's/strings from the .resx file. What else? Will it effect my date/money formatting also? ...

For a class to use CultureInfo.CurrentCulture, it has to have a context correct?

If a class library method references CultureInfo.CurrentCulture, the calling client has to be running with a HttpContext correct? ...

Display Date based on culture but Time based on a pattern

Does anybody know how to display the date of a datetime based on a CurrentCulture but the Time follow this pattern "HH:mm:ss.fff" ? I've tried to use: DateTime NewDate = DateTime.Now; NewDate.ToString(CultureInfo.CurrentCulture); It results: 4-6-2010 14:49:41. Expected: 4-6-2010 14.49.41,495. For the Time, I also need to show the mi...

Get just the hour of day from DateTime using either 12 or 24 hour format as defined by the current culture

.Net has the built in ToShortTimeString() function for DateTime that uses the CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern format. It returns something like this for en-US: "5:00 pm". For a 24 hour culture such as de-DE it would return "17:00". What I want is a way to just return just the hour (So "5 pm" and "17" in the ca...

Can CultureInfo.CurrentCulture differ per application pool?

I'm having trouble with CultureInfo in our ASP.NET web application. Our web application returns a different culture, depending on which application pool it is in. In application pool A, it is en-US, but in application pool B, it's nl-BE. I'd like it to be nl-BE, but can't find where to change this (IIS6 by the way). I'm not even sure ...

Silverlight (RIA Services) spontaneous culture changing

My RIA enabled Silverlight Application is setting the thread culture in the App constructor (this is absolutley okay since it is an intranet application and will never ever be used by someone who is not german): public App() { InitializeComponent(); Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE"); } It does what...

Date in textboxes changing format

I have an application (asp.net 3.5) that support 4 different languages. Along with other cultural changes, the date formats must match the current culture on out reporting pages. We set the date formats of each of the textboxes like: string date = DateTime.Today.ToString("d"); //returns the date portion only textbox1.Text = date; tex...

Change culture of Silverlight application

Hi, I am working on a Silverlight app at the moment. I have a few datagrids/textblocks where I use standard binding to show values, some of which are dates. e.g. <sdk:DataGrid AutoGenerateColumns="False" IsReadOnly="True" ItemsSource="{Binding Path=MyCollection}"> <sdk:DataGrid.Columns> <sdk:DataGridTextColumn Binding="{Binding ...

Setting the Culture in ASP.NET

I have an asp:literal: <asp:Literal id="language" OnClick="changeLangauge" Text="<%$ Resources:Translate, switchLanguage %>" runat="server"/> When it is clicked it switches the language: public void ChangeLanguage(Object sender, EventArgs e) { string lang = langauge.Attribues["class"]; language.Attributes.Remove("class"); if (l...

Adding Updating and Deleting Key Value From Resource File Programmatically

I was dealing with Resource Files in .NET, Currently I adds each key, value pair manually and want to automate most of the things. Is it possible to add, update and delete any key value pair from existing resource file. ...

How to see resource file content in Visual Studio when created pro programmatically

I created a resource file programmatically. File got created successfully. But when I tries to open it in Visual Studio or notepad it shows me some encoded characters. I was expecting to get an XML. Here is what I was expecting and getting. What I did in coding is ResourceWriter rw = new ResourceWriter("Resource.en.resx"); r...

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