globalization

DateTime problems when moving to production environment

微笑、不失礼 提交于 2019-12-10 18:32:31
问题 I have several forms within my MVC app that have date values which are chosen via a datepicker tool. This works well when debugging locally but on deployment to the cloud environment my dates are not being correctly converted. I have the following code: string[] uploaddate = form.GetValues("uploaddate"); string[] expirydate = form.GetValues("expirydate"); This gets the date as 31/08/2013 etc. and from here I was converting to DateTime as follows: Convert.ToDateTime(uploaddate[0]); Convert

MVC 3 Setting uiCulture does not work

我的未来我决定 提交于 2019-12-10 17:52:49
问题 I'm using MVC3 in c#. I have added in Web.Config this code, with the goal to set the formatting of in UK format. .... <globalization uiCulture="en-GB" culture="en-GB"/> </system.web> Unfortunately the text are still displayed in US format. Could you tell me what I'm doing wrong here? 回答1: This was answered in the post "Change culture based on a link MVC4". You need to inherit your Controller from a BaseController, override the BaseController's Initialize method, and use a cookie. This is not

How to change the data format for the current culture so that it applies to the entire web application

你说的曾经没有我的故事 提交于 2019-12-10 15:29:35
问题 I would like to set the date format to ' YYYY-MM-DD ' for my entire web application. I can do this by creating an object of CultureAndRegionInfoBuilder and then registering it. But since my application is on a hosted environment , I cannot run executables to register the culture. I need a way to do this within the Application_Start so that it applies to the entire web app. I tried changing the date format using Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern , but it does

Get culture-specific date with 2 digit year in C#

天大地大妈咪最大 提交于 2019-12-10 13:32:36
问题 I'm updating some code that formats a date to a string using "MM/dd/yy". I need it to be culture aware, but want to keep the two digit year in order to keep the date short. Below is what I came up with, but is there a better way? string dateFormat = culture_Info.DateTimeFormat.ShortDatePattern.Replace("yyyy", "yy"); 回答1: I don't know of any way, no (and I've looked at the formatting reasonably extensively). What you've got obviously still leaves a bit of a nasty taste in the mouth, but I

Floating Point Number parsing: Is there a Catch All algorithm?

别来无恙 提交于 2019-12-10 12:37:54
问题 One of the fun parts of multi-cultural programming is number formats. Americans use 10,000.50 Germans use 10.000,50 French use 10 000,50 My first approach would be to take the string, parse it backwards until I encounter a separator and use this as my decimal separator. There is an obvious flaw with that: 10.000 would be interpreted as 10. Another approach: if the string contains 2 different non-numeric characters, use the last one as the decimal separator and discard the others. If I only

Is there a way to avoid using hard-coded resw keys with the windows store app ResourceLoader?

我是研究僧i 提交于 2019-12-10 12:27:02
问题 Is there a way to avoid using hard-coded keys for the globalized strings contained in the resw file within a windows store app? i.e. // I have to use a hard-coded string key, which may violate the // DRY principle to gain access to the translation from C#: var translation = Windows.ApplicationModel.Resources.ResourceLoader.GetString("MyStringKey/Text") 回答1: You can use the T4 template below to automatically generate a C# wrapper around your resw file. This means you have no need to litter

Detect culture of number in VB.Net i.e. period or comma for decimal point / thousands separator

大城市里の小女人 提交于 2019-12-10 10:29:37
问题 In VB.Net, is there a way of auto-detecting the culture of a string representation of a number? I'll explain the situation: Our asp.net web site receives xml data feeds for boat data. Most of the time, the number format for the prices use either a simple non-formatted integer e.g. "999000". That's easy for us to process. Occaisionally, there are commas for thousands separators and periods for the decimal point. Also, that's fine as our data import understands this. Example "999,000.00". We're

Are there localization tools which spot content strings in xaml/wpf?

此生再无相见时 提交于 2019-12-10 07:10:17
问题 When globalizing a wpf application with static resx classes, it's very easy to miss the odd label or button that has its Content property set to a hard coded string in a particular language, ie English. These should of course be moved off to a {x:Static ...} so they can be localised for each culture. Are there any tools which can spot this and warn you? Built in to VS would be ideal, but I'm thinking that 'style cop' type build tools would do the job as well. 回答1: David Anson posted just such

InitializeCulture() on every single page necessary?

我们两清 提交于 2019-12-10 00:00:55
问题 I have a web forms site that needs to be localized. I mean, it is localized, I just need to set the right language according to the domain. Something like: protected override void InitializeCulture() { var i = Request.Url.Host.ToLower(); var domain = i.Substring(i.Length - 2, 2); if (domain == "se") { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("sv-SE"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("sv-SE"); } else if (domain == "dk") { Thread

knockout js and globalization

 ̄綄美尐妖づ 提交于 2019-12-09 17:21:38
问题 I can't figure out how to handle calculations using knockout js and a non us locale. My comma is , and is validated correctly using the jquery.globalization plugin but the knockout calculation is giving me a NaN. Does knockout js support this in any way or does it exist any workarounds? Example: Make the cartEditor example on the knockout js site work allowing decimal values in the quantity field and allowing globalized input (, as comma sign) and output formatting http://knockoutjs.com