globalization

Handling timezones in storage?

家住魔仙堡 提交于 2019-11-26 22:48:49
问题 Store everything in GMT? Store everything the way it was entered with an embedded offset? Do the math everytime you render? Display relative Times "1 minutes ago"? 回答1: You have to store in UTC - if you don't, your historic reporting and behaviour during things like Daylight Savings goes... funny. GMT is a local time, subject to Daylight Savings relative to UTC (which is not). Presentation to users in different time-zones can be a real bastard if you're storing local time. It's easy to adjust

Get current language in CultureInfo

 ̄綄美尐妖づ 提交于 2019-11-26 20:51:21
问题 How to identify the operating system's language using CultureInfo ? E.g. if the language in Windows is set to French, I need to identify French and load the fr resource files data. 回答1: I think something like this would give you the current CultureInfo: CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; Is that what you're looking for? 回答2: This is what i used: var culture = System.Globalization.CultureInfo.CurrentCulture; and it's working :) 回答3: Current system language is

Currency format for display

◇◆丶佛笑我妖孽 提交于 2019-11-26 20:51:14
Is there a library to format the correct currency represent for a country? Example UK -£127.54 Netherlands € 127,54- USA $127.54 etc.. Some things to consider, Currency Symbol Currency symbol placement -- It can be either place before or after the digits. Negative-amount display Try the Currency Format Specifier ("C"). It automatically takes the current UI culture into account and displays currency values accordingly. You can use it with either String.Format or the overloaded ToString method for a numeric type. For example: double value = 12345.6789; Console.WriteLine(value.ToString("C",

Converting country codes in .NET

烈酒焚心 提交于 2019-11-26 19:34:26
问题 In .NET is there any way to convert from three letter country codes (defined in ISO 3166-1 alpha-3) to two letter language codes (defined in ISO 3166-1 alpha-2) eg. convert BEL to BE? Have looked at the RegionInfo class in System.Globalization but the constructor does not seem to support the three letter codes. 回答1: The RegionInfo class does know the three-letter code (in the ThreeLetterISORegionName property), but I don’t think there is a way to get RegionInfo based on this code, you would

What is the “best” way to store international addresses in a database?

只愿长相守 提交于 2019-11-26 19:34:21
问题 What is the " best " way to store international addresses in a database? Answer in the form of a schema and an explanation of the reasons why you chose to normalize (or not) the way you did. Also explain why you chose the type and length of each field. Note: You decide what fields you think are necessary. 回答1: Plain freeform text. Validating all the world's post/zip codes is too hard; a fixed list of countries is too politically sensitive; mandatory state/region/other administrative

Multilanguage in WPF [closed]

走远了吗. 提交于 2019-11-26 19:02:37
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 years ago . Can you recommend a good way to implement a Multilanguage system for a WPF app? The method I'm using right now involves XML, classes and a xaml extension. It Works fine in most of cases, but when I have to deal with dynamic labels or dynamic text in general it require some extra

Difference between CurrentCulture, InvariantCulture, CurrentUICulture and InstalledUICulture

雨燕双飞 提交于 2019-11-26 18:50:53
问题 What is the difference between CurrentCulture , InvariantCulture , CurrentUICulture and InstalledUICulture from System.Globalization.CultureInfo ? 回答1: I would try to give a bit more insightful answer than this one. CurrentCulture should be used for formatting. That is, Numbers, Currencies, Percentages, Dates and Times should always be formatted with this culture before displaying them to user . Few examples here: const string CURRENCY_FORMAT = "c"; const string PERCENTAGE_FORMAT = "p";

How do I set CultureInfo.CurrentCulture from an App.Config file?

喜夏-厌秋 提交于 2019-11-26 17:47:04
问题 I need to set my application's culture through an App.Config file, so that "pt-BR" is used automatically for parsing dates without the need to manually inform the culture for each operation. As far as I know, there's a globalization section that can be defined inside the system.web section in a Web.Config file, but I'm running a console application and I can't figure this out. Any idea? 回答1: I don't know a built-in way to set it from App.config, but you could just define a key in your App

Can You Determine Timezone from Request Variables?

元气小坏坏 提交于 2019-11-26 17:43:10
Is there a way to do your timezone offsets on the server side, by reading something in the request over http, instead of sending everything to the client and letting it deal with it? This is more complicated but I've had to resort to this scenario before because machine and user profile settings sometimes don't match your visitor's preferences. For example, a UK visitor accessing your site temporarily from an Australian server. Use a geolocation service (e.g MaxMind.com) as suggested by @balabaster, to get the zone matching their IP (Global.Session_Start is best). This is a good match for

String format currency

↘锁芯ラ 提交于 2019-11-26 16:24:55
I have this line @String.Format("{0:C}", @price) in my razor view. I want it to display a dollar sign in front of the price but instead it display a pound sign. How do I achieve this? I strongly suspect the problem is simply that the current culture of the thread handling the request isn't set appropriately. You can either set it for the whole request, or specify the culture while formatting. Either way, I would suggest not use string.Format with a composite format unless you really have more than one thing to format (or a wider message). Instead, I'd use: @price.ToString("C", culture) It just