Search Results

Search found 273 results on 11 pages for 'cultureinfo'.

Page 1/11 | 1 2 3 4 5 6 7 8 9 10 11  | Next Page >

  • C# CultureInfo NumberFormat NumberDecimalSeparator Problem

    - by Mahdi
    I want to change NumberDecimalSeparator of my application from "." to "/". it works when i show float numbers in my textbox. but integer types are not shown at all. I modify thread's culture to get application-wide formatting. my code is like this: CultureInfo ci = new CultureInfo("fa-IR", true); ci.NumberFormat.DigitSubstitution = DigitShapes.NativeNational; ci.NumberFormat.NumberDecimalSeparator = "/"; Thread.CurrentThread.CurrentCulture = ci; result: 3.14 = "3/14" 100 = "" Any help please ?

    Read the article

  • Can CultureInfo.CurrentCulture differ per application pool?

    - by Peter
    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 if this can be changed on an app-pool level. I'm checking with CultureInfo.CurrentCulture.Name. Is it possible to change this for an application pool? Or what else could influence this? In the regional settings of the server, we have selected 'Dutch (Belgium)', which translates to nl-BE, I believe. So where could this application pool be getting the en-US?

    Read the article

  • CultureInfo on a IValueConverter implementation

    - by slugster
    When a ValueConverter is used as part of a binding, one of the parameters to the Convert function is a System.Globalization.CultureInfo object. Can anyone tell me where this culture object gets its info from? I have some code that formats a date based on that culture. When i access my silverlight control which is hosted on my machine, it formats the date correctly (using the d/MM/yyyy format, which is set as the short date format on my machine). When i access the same control hosted on a different server (from my client machine), the date is being formatted as MM/dd/yyyy hh:mm:ss - which is totally wrong. Coincidentally the regional settings on the server are set to the same as my client machine. This is the code for my value converter: public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is DateTime) { if (parameter != null && !string.IsNullOrEmpty(parameter.ToString())) return ((DateTime)value).ToString(parameter.ToString()); else return ((DateTime)value).ToString(culture.DateTimeFormat.ShortDatePattern); } return value; } basically, a specific format can be specified as the converter parameter, but if it isn't then the short date pattern of the culture object is used.

    Read the article

  • Missing Countries & locations from CultureInfo when trying to

    - by Ian
    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 correct text and such? Thanks

    Read the article

  • Change CulturalInfo after button click

    - by Bart
    i have multilingual asp.net site. there is masterpage and default.aspx in masterpage i put two buttons one to click when i want to change the language to english, second for polish. 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 both: protected void EnglishButton_Click(object sender, ImageClickEventArgs e) { string selectedLanguage = "en-US"; //Sets the cookie that is to be used by InitializeCulture() in content page HttpCookie cookie = new HttpCookie("CultureInfo"); cookie.Value = selectedLanguage; Response.Cookies.Add(cookie); Server.Transfer(Request.Path); } protected void PolishButton_Click(object sender, ImageClickEventArgs e) { string selectedLanguage = "pl-PL"; //Sets the cookie that is to be used by InitializeCulture() in content page HttpCookie cookie = new HttpCookie("CultureInfo"); cookie.Value = selectedLanguage; Response.Cookies.Add(cookie); Server.Transfer(Request.Path); } in default.aspx.cs i have InitializeCulture(): protected override void InitializeCulture() { HttpCookie cookie = Request.Cookies["CultureInfo"]; // if there is some value in cookie if (cookie != null && cookie.Value != null) { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cookie.Value); Thread.CurrentThread.CurrentUICulture = new CultureInfo(cookie.Value); } else // if none value has been sent by cookie, set default language { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("pl-PL"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("pl-PL"); } base.InitializeCulture(); } i added resource files and in one label i show actual culture: Welcome.Text = "Culture: " + System.Globalization.CultureInfo.CurrentCulture.ToString(); the problem is that when i run this app and click e.g. english button (default language is polish), there is no effect. if i click it second time or press F5, the changes are applies and in the label is Culture: en-US. the same happens if i want to change language back to polish (it works after second click (or one click and refresh)). What am i doing wrong?

    Read the article

  • [ASP.NET] Change CulturalInfo after button click

    - by Bart
    Hello, i have multilingual asp.net site. there is masterpage and default.aspx in masterpage i put two buttons one to click when i want to change the language to english, second for polish. 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 both: protected void EnglishButton_Click(object sender, ImageClickEventArgs e) { string selectedLanguage = "en-US"; //Sets the cookie that is to be used by InitializeCulture() in content page HttpCookie cookie = new HttpCookie("CultureInfo"); cookie.Value = selectedLanguage; Response.Cookies.Add(cookie); Server.Transfer(Request.Path); } protected void PolishButton_Click(object sender, ImageClickEventArgs e) { string selectedLanguage = "pl-PL"; //Sets the cookie that is to be used by InitializeCulture() in content page HttpCookie cookie = new HttpCookie("CultureInfo"); cookie.Value = selectedLanguage; Response.Cookies.Add(cookie); Server.Transfer(Request.Path); } in default.aspx.cs i have InitializeCulture(): protected override void InitializeCulture() { HttpCookie cookie = Request.Cookies["CultureInfo"]; // if there is some value in cookie if (cookie != null && cookie.Value != null) { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cookie.Value); Thread.CurrentThread.CurrentUICulture = new CultureInfo(cookie.Value); } else // if none value has been sent by cookie, set default language { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("pl-PL"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("pl-PL"); } base.InitializeCulture(); } i added resource files and in one label i show actual culture: Welcome.Text = "Culture: " + System.Globalization.CultureInfo.CurrentCulture.ToString(); the problem is that when i run this app and click e.g. english button (default language is polish), there is no effect. if i click it second time or press F5, the changes are applies and in the label is Culture: en-US. the same happens if i want to change language back to polish (it works after second click (or one click and refresh)). What am i doing wrong? Regards, Bart

    Read the article

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

    - by Henrik Carlsson
    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") -> 8 int.Parse("8100") -> 100 CurrentCulture: sv-SE CurrentUICulture: en-US The problem is solved using int.Parse("8", CultureInfo.InvariantCulture). However, it would be nice to know the source of the problem. Question: Why do we get this behaviour of "8" if we don't specify invariant culture? Additional information: I did send a small program to my client achieve the result above: private int ParseInt(string s) { int parsedInt = -1000; try { parsedInt = int.Parse(s); textBoxMessage.Text = "Success: " + parsedInt; } catch (Exception ex) { textBoxMessage.Text = string.Format("Error parsing string: '{0}'", s) + Environment.NewLine + "Exception message: " + ex.Message; } textBoxMessage.Text += Environment.NewLine + Environment.NewLine + "CurrentCulture: " + Thread.CurrentThread.CurrentCulture.Name + "\r\n" + "CurrentUICulture: " + Thread.CurrentThread.CurrentUICulture.Name + "\r\n"; return parsedInt; }

    Read the article

  • C++ Win32 API equivalent of CultureInfo.TwoLetterISOLanguageName

    - by Brian Gillespie
    The .NET framework makes it easy to get information about various locales; the Win32 C++ APIs are a bit harder to figure out. Is there an equivalent function in Win32 to get the two-letter ISO language name given an integer locale ID? In C# I'd do: System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(1034); string iso = ci.TwoLetterISOLanguageName; // iso == "es" now.

    Read the article

  • Application hangs after changing language From “En-Us” to any global language in control panel

    - by user1764824
    I created a WinForms application using C#. When I try to change the culture info, my application gets hanged. Microsoft.Win32.SystemEvents.UserPreferenceChanged += new Microsoft.Win32.UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged); void SystemEvents_UserPreferenceChanged(object sender, Microsoft.Win32.UserPreferenceChangedEventArgs e) { if (!PreviousInstance()) { CultureInfo ObjCulture = new CultureInfo(CultureInfo.InvariantCulture.IetfLanguageTag, false); Thread.CurrentThread.CurrentCulture = ObjCulture; Application.CurrentCulture = ObjCulture; } } public void INIT() { CultureInfo objCultureInfo = null; try { objCultureInfo = new CultureInfo("en-US", false); objCultureInfo.NumberFormat.NumberDecimalSeparator = "."; objCultureInfo.NumberFormat.NegativeSign = "-"; objCultureInfo.NumberFormat.NumberNegativePattern = 1; //1 stands for -100. Application.CurrentCulture = objCultureInfo; } } After Changing Language ... My Application gets Hanged and i cant Debug anything When i Try to Evaluate things This Event Called only once.. But if try in a small application it comes every time when Language is changed... ... Nothing shown in Eventviewer either. How can I solve this problem? ..

    Read the article

  • Convert any currency string to double

    - by James
    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 when displaying. However, I have tried doing something like e.g. var cultureInfo = new System.Globalization.CultureInfo("en-US"); double plain = return Double.Parse("$20,000.00", cultureInfo); This doesn't ever seem to work it always throws a FormatException. Even removing the currency symbol and just trying to do this based on the number alone does the same thing. This is just an example I want to support pretty much any type of currency. Is there a standard way of stripping out currency and getting the value as a double?

    Read the article

  • Issue with Callback method and maintaining CultureInfo and ASP.Net HttpRuntime

    - by Little Larry Sellers
    Hi All, Here is my issue. I am working on an E-commerce solution that is deployed to multiple European countries. We persist all exceptions within the application to SQL Server and I have found that there are records in the DB that have a DateTime in the future! We define the culture in the web.config, for example pt-PT, and the format expected is DD-MM-YYYY. After debugging I found the issue with these 'future' records in the DB is because of Callback methods we use. For example, in our Caching architecture we use Callbacks, as such - CacheItemRemovedCallback ReloadCallBack = new CacheItemRemovedCallback(OnRefreshRequest); When I check the current threads CultureInfo, on these Callbacks it is en-US instead of pt-PT and also the HttpContext is null. If an exception occurs on the Callback our exception manager reports it as MM-DD-YYYY and thus it is persisted to SQL Server incorrectly. Unfortunately, in the exception manager code, we use DateTime.Now, which is fine if it is not a callback. I can't change this code to be culture specific due to it being shared across other verticals. So, why don't callbacks into ASP.Net maintain context? Is there any way to maintain it on this callback thread? What are the best practices here? Thanks.

    Read the article

  • how to convert string to double with proper cultureinfo

    - by Vinay Pandey
    Hi All, I have two nvarchar fields in database to store the DataType and DefaultValue, I have a DataType Double and value as 65.89875 in english format. Now I want the user to see the value as per the selected browser language format (65.89875 in English should be displayed as 65,89875 in german). Now if the user edits from german format to 65,89875 which is 65.89875 equivalent in english, and the other user views from english browser it comes as 6589875. This happens because in DB it was stored as 65,89875 and when converted using english culture it becomes 6589875 since it considers , as seperator. Any Idea how I get this working for all the browsers?

    Read the article

  • Double.Parse - Internationalization problem

    - by oz
    This is driving me crazy. I have the following string in a ASP.NET 2.0 WebForm Page string s = "0.009"; Simple enough. Now, if my culture is Spanish - which is "es-ES" - and I try to convert the string to Double, I do the following: double d = Double.Parse(s, new CultureInfo("es-ES")); what I'd expect is 0,009. Instead, I get 9. I understand that .NET thinks it is a thousand separator, which in en-US is a comma, but shouldn't it take the culture info I'm passing to the parse method and apply the correct format to the conversion? If I do double d = 0.009D; string formatted = d.ToString(new CultureInfo("es-ES")); formatted is now 0,009. Anybody?

    Read the article

  • Convert.ToDateTime causes FormatException on afternoon date/time values

    - by Sam
    We have an application parsing date/time values in the following format: 2009-10-10 09:19:12.124 2009-10-10 12:13:14.852 2009-10-10 13:00:00 2009-10-10 15:23:32.022 One particular server all of the sudden (today) started failing to parse any times 13:00:00 or later. This particular client has five servers and only one has the problem. We have dozens of other clients with a total of hundreds of servers without the problem. System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider provider) at System.Convert.ToDateTime(String value, IFormatProvider provider) at System.String.System.IConvertible.ToDateTime(IFormatProvider provider) at System.Convert.ToDateTime(Object value) I ran a test using DateTime.Parse(s, CultureInfo.CurrentCulture) comapred to DateTime.Parse(s, CultureInfo.InvariantCulture) and the problem only shows up with CurrentCulture. However, CurrentCulture is "en-US" just like all the other servers and there's nothing different that I can find in regional or language settings. Has anyone seen this before? Suggestions related to what I can look into? EDIT: Thank you for the answers so far. However, I'm looking for suggestions on what configuration to look into that could have caused this to suddenly change behavior and stop working when it's worked for years and works on hundreds of other servers. I've already changed it for the next version, but I'm looking for a configuration change to fix this in the interim for the current installation.

    Read the article

  • Convert text from English characters to Hebrew characters

    - by Ovi
    Using C#, when a user types a text in a normal textbox, how can you see the Hebrew equivalent of that text? I want to use this feature on a data entry form, when the secretary puts in the customer name using English characters to have it converted automatically in another textbox to the hebrew representation. Maybe something with CultureInfo("he-IL")...

    Read the article

  • VSTS test deployment and invalid assembly culture

    - by Merlyn Morgan-Graham
    I have a DLL that I'm testing, which links to a DLL that has what I think is an invalid value for AssemblyCulture. The value is "Neutral" (notice the upper-case "N"), whereas the DLL I'm testing, and every other DLL in my project, has a value of "neutral" (because they specify AssemblyCulture("")). When I try to deploy the DLL that links to the problem DLL, I get this error in VSTS: Failed to queue test run '...': Culture is not supported. Parameter name: name Neutral is an invalid culture identifier. <Exception>System.Globalization.CultureNotFoundException: Culture is not supported. Parameter name: name Neutral is an invalid culture identifier. at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride) at System.Globalization.CultureInfo..ctor(String name) at System.Reflection.RuntimeAssembly.GetReferencedAssemblies(RuntimeAssembly assembly) at System.Reflection.RuntimeAssembly.GetReferencedAssemblies() at Microsoft.VisualStudio.TestTools.Utility.AssemblyLoadWorker.ProcessChildren(Assembly assembly) at Microsoft.VisualStudio.TestTools.Utility.AssemblyLoadWorker.GetDependentAssemblies(String path) at Microsoft.VisualStudio.TestTools.Utility.AssemblyLoadWorker.GetDependentAssemblies(String path) at Microsoft.VisualStudio.TestTools.Utility.AssemblyLoadStrategy.GetDependentAssemblies(String path) at Microsoft.VisualStudio.TestTools.Utility.AssemblyHelper.GetDependentAssemblies(String path, DependentAssemblyOptions options, String configFile) at Microsoft.VisualStudio.TestTools.TestManagement.DeploymentManager.GetDependencies(String master, String configFile, TestRunConfiguration runConfig, DeploymentItemOrigin dependencyOrigin, List`1 dependencyDeploymentItems, Dictionary`2 missingDependentAssemblies) at Microsoft.VisualStudio.TestTools.TestManagement.DeploymentManager.DoDeployment(TestRun run, FileCopyService fileCopyService) at Microsoft.VisualStudio.TestTools.TestManagement.ControllerProxy.SetupTestRun(TestRun run, Boolean isNewTestRun, FileCopyService fileCopyService, DeploymentManager deploymentManager) at Microsoft.VisualStudio.TestTools.TestManagement.ControllerProxy.SetupRunAndListener(TestRun run, FileCopyService fileCopyService, DeploymentManager deploymentManager) at Microsoft.VisualStudio.TestTools.TestManagement.ControllerProxy.QueueTestRunWorker(Object state)</Exception> Even if I don't link to the DLL (in my VSTS wrapper test, or in the NUnit test), as soon as I add it in my GenericTest file (I'm wrapping NUnit tests), I get that exception. We don't have the source for the problem DLL, and it is also code signed, so I can't solve this by recompiling. Is there a way to skip deploying the dependencies of a DLL DeploymentItem, to fix or disable the culture check, or to work around this by convoluted means (maybe somehow embed the assembly)? Is there a way to override the value for the culture, short of hacking the DLL (and removing code signing so the hack works)? Maybe with an external manifest? Any correct solution must work without weird changes to production code. We can't deploy a hacked DLL, for example. It also must allow the DLL to be instrumented for code coverage. Additional note: I do get a linker warning when compiling the DLL under test that links to the problem DLL, but this hasn't broken anything but VSTS, and multiple versions have shipped.

    Read the article

  • Globalization for GetSystemTimeZones()

    - by user300992
    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 English. How can I pass the cultureInfo so that it can return other languages? I tried setting the Thread.CurrentCulture and CurrentUICulture, it didn't work. Am I missing something?

    Read the article

  • How to convert culture specific double using TypeConverter?

    - by Christian
    Hi I have a problem with the TypeConverter class. It works fine with CultureInvariant values but cannot convert specific cultures like english 1000 seperators. Below is a small test program that I cannot get to work. using System; using System.Globalization; using System.ComponentModel; namespace TestConvertCulture { class Program { static void Main() { try { var culture = new CultureInfo( "en" ); TypeConverter typeConverter = TypeDescriptor.GetConverter( typeof ( double ) ); double value = (double)typeConverter.ConvertFromString( null, culture, "2,999.95" ); Console.WriteLine( "Value: " + value ); } catch( Exception e ) { Console.WriteLine( "Error: " + e.Message ); } } } }

    Read the article

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

    - by dradovic
    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: de-DE (note the comma) DateTime d = DateTime.Parse(s); // throws a FormatException It is weird to me that DateTime.Parse(s) should throw a FormatException now as it is supposed to use the CultureInfo.CurrentCulture to do the parsing. Even passing the CurrentCulture as an argument explicitly does not help neither. Does anybody have an idea why this does not work? Doesn't parsing take the NumberFormatInfo.NumberDecimalSeparator into account?

    Read the article

  • How to get DayNames from language only in .NET

    - by ManniAT
    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-US for en or de-DE for de. I don't know if there are differences in DayNames but I know there are some for the months. de-DE Februar - de-AT Feber -- anyhow I don't care. Event if it may be "a bit different" (to see Februar instead of Feber) - it is still German. And that's what I want to achive - get en an write Monday - get de and write Montag... Is there a way to create a region just from a language code?

    Read the article

  • Globally overrride MonthNames for all instances of a specific culture

    - by Pauli Østerø
    So, i have this problem where Microsoft actually got the month names wrong for the Greenlandic culture (kl-GL). I also know that i can pass my own array of string to the DateTimeFormatInfo.MonthNames Property, but it seems like the values i specify is only used in the scope of that one CultureInfo instance. Is there a way to tell .Net that every time i have an instance of the kl-GL culture these specific monthnames should be used? I know that you can create user specific cultures, but i don't have access to some legacy code to actually change the code to use a my own userspecified culture.

    Read the article

1 2 3 4 5 6 7 8 9 10 11  | Next Page >