cultureinfo

How to get DayNames from language only in .NET

Assume that I only have a country code (en, de, fr) and I need to display the weekdays in this language. I know about RegionInfo and CultureInfo - but I can't find a solution. If I create a country info from (for an example) "en" I have no DateTime info in it. It would also be OK to just take the first matching Region. For an example en-...

Change CulturalInfo after button click

i have multilingual asp.net site. there is a masterpage and default.aspx. I put two buttons in masterpage - one to click when i want to change the language to english, second for polish. Of course, I want to change the language after click on these buttons (and all changes should appear automatically on the page) here is a code for bo...

How to convert culture specific double using TypeConverter?

Hi, I have a problem with the TypeConverter class. It works fine with CultureInvariant values but cannot convert specific cultures like English thousands separators. Below is a small test program that I cannot get to work. Here's the problem :) - ConvertFromString throws an exception with the following message "2,999.95 is not a valid v...

int.Parse of "8" fails. int.Parse always requires CultureInfo.InvariantCulture?

We develop an established software which works fine on all known computers except one. The problem is to parse strings that begin with "8". It seems like "8" in the beginning of a string is a reserved character. Parsing: int.Parse("8") -> Exception message: Input string was not in a correct format. int.Parse("80") -> 0 int.Parse("88") ...

Convert any currency string to double

I need to store multiple currencies in SQL server. I understand that SQL won't support all different types of currencies (unless I store it as a string, but I don't want to do that). My idea was to convert all the values from their currency format to a standard double and store that instead. Then just re-format based on the culture info...

Get the currency from current culture?

Is there a way to get current information dynamically from the apps culture settings? Basically if the user has set the culture to US I want to know the currency is dollars, or if they have it set to UK I want to pound sterling etc... etc.. This is so I can send this information to PayPal when a payment is being made ...

Silverlight 4 how to format a binded decimal value

Hey, sorry for my bad english... I have a very simple textbox on my sl4 app, like this: <TextBox Text="{Binding Source={StaticResource Valor}, Path=ValorReal, ValidatesOnExceptions=True, Mode=TwoWay, ValidatesOnDataErrors=True, StringFormat=\{0:c\}, NotifyOnValidationError=True}" /> and a class like: public class Valor: INotifyPrope...

Parsing a DateTime containing milliseconds fails for certain cultures. Why?

I'm trying to parse a string containing milliseconds like this: string s = "11.05.2010 15:03:08.7718687"; // culture: de-CH DateTime d = DateTime.Parse(s); // works However, for example under the de-DE locale, the decimal separator is a comma (not a dot). So the example becomes: string s = "11.05.2010 15:03:08,7718687"; // culture...

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

Missing Countries & locations from CultureInfo when trying to

Hi All, I need to localize an application and have noticed that several countries don't appear in the list of county codes associated to cultureInfo. One example is Cyprus, I assume there might be others. If i need to localize settings for Cyprus (or other missing ones) how would I rename my resource files that they would render the c...

Globalization for GetSystemTimeZones()

I want to get a list of timezones, so that i can populate the dropdown list. In .NET 3.5, we have TimeZoneInfo namespace, here is the code: ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones(); foreach (TimeZoneInfo timeZone in timeZones) string name = timeZone.DisplayName However, "DisplayName" is in En...

CultureInfo.DisplayName going Sami on me

Why is CultureInfo.DisplayName in Sami all of a sudden? I use it to display a list of country names. Not a good idea perhaps but it worked until recently and I'm quite sure it was in Swedish (I guess it could have been English.) MSDN says This property represents the localized name from the .NET Framework version. For example, if t...

.Net Culture Insensitive Comparisons - Example of when this is needed

I am revising for the MCTS example and am on a small section regarding Culture-Insensitive comparisons. I get the principle, you don't two items which are the same (i.e dates) but are displayed differently and hence are pragmatically marked as different. However call me stupid but I am finding it hard to see where I can use it is pract...

where does IValueConverter.Convert source the CultureInfo parameter from?

I'm going through some silverlight apps and reviewing date formatting to make sure the presentation is appropriate for the viewer. with an implementation of IValueConverter, where does the culture parameter come from in the Convert/ConvertBack functions? it seems to not be CultureInfo.CurrentCulture which I think is what I want. ...

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

City Culture/History Information

Is there a provider who would provide information about a city's - it's history, Climate, Major religions, Language Distribution, important attractions .. I checked stackoverflow earlier and from this I see an option of using Wikipedia - either scrape the screen or use DBPedia, WEX and others. I would like to know if there is any provi...

String.Format not converting integers correctly in arabic

I have a problem with String.Format. The following code formats the string correctly apart from the first integer. Current culture is set to Iraqi arabic (ar-IQ): int currentItem= 1; string of= "من"; int count = 2; string formatted = string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}", currentItem, of, count); The text is formatted ...

CultureInfo.CurrentCulture is giving me the wrong culture

I'm trying to get my clients' country, so I use CultureInfo.CurrentCulture. Problem is that when my Canadian customers use my website, they're showing up as American. It looks like CultureInfo.CurrentCulture is returning my server's country instead of their country. So how do I get my clients' country? ...

Why not all countries are presented in CultureInfo.GetCultures()?

I am using this standard code for populating list of countries: static void Main(string[] args) { List cultureList = new List(); CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures); foreach (CultureInfo culture in cultures) { try { Regio...

Get Preferred Culture Info / Language - C#, ASP.NET

I am trying to get the users preferred language. I see all kinds of articles on how to set it, but they assume that the user is telling it which language to select (like in a dropdownlist). In Firefox under Tools > Options > Content > Languages > Choose you can select which languages you prefer and choose their order. I want to be ab...