globalization

Opposite method to toLocaleDateString

本秂侑毒 提交于 2019-12-06 13:50:12
问题 In order to create a string that respects the browser culture, we can do: var myDate = new Date(); var myDateString = myDate.toLocaleDateString(myDate); //returns a string Which is nice, because if I'm in Portugal, for the 1st of June, this will output "01/06/2015", while if I'm on the states, it will output "06/01/2015". Now I want the exact opposite. I want: var myDateString = "01/06/2015" var myDate = myDateString.toLocaleDate(); //it should return a Date Any suggestions? 回答1: Browsers

Get current culture using just formula for localization purpose

三世轮回 提交于 2019-12-06 10:52:07
Is there a way how to determine current system culture using a formula in Excel wihout using any VBA code ? I imagine something simple like this: IF(CULTURE="sk-SK","Prehľad","Overview") or also something like this would do for me: IF(CURRENCYSIGN="€","Prehľad","Overview") I am looking for a simple way to globalize XLSX file without any additional resources or files needed. No, there is no way to get system language settings without VBA. There is simply no built-in function for this. But if you consider UDF, there's a solution: Public Function GetLang() GetLang = Application.LanguageSettings

Globalization in ASP.net MVC (Resource file per View vs Domain)

懵懂的女人 提交于 2019-12-06 08:19:05
问题 What is the best practice for keeping Resource files when it comes to ASP.net MVC globalization ? For Example, we have order processing system if we try to keep our resource files for domain i.e order.resx, customer.resx, etc or else we could try to keep resource files per view i.e OrderProcessingView.resx, CustomerView.resx, etc Common strings such as "Add", "Edit", "Delete" can handle by using common.resx file. Or Are there any other approaches to keep the resource files ? We are using some

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

狂风中的少年 提交于 2019-12-06 06:30:34
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 starting to get some data from France where some of the prices have been entered with the periods and

Localization. Extending ASP.NET Resx Resource Provider

試著忘記壹切 提交于 2019-12-06 06:09:03
问题 For my website I have a custom resource provider for localization purposes (localized strings are stored in database). It works just fine, but I would like it to work with the default Resx Resource Provider: look up localized string in resx resources and if doesn't exist then pull it from the database. But it looks that as soon as I change IIS globalization setting to use my own resource provider factory, then the default resx resource provider factory gets ignored. I guess the solution would

DateTime supported language for formatting?

一曲冷凌霜 提交于 2019-12-06 06:04:05
DateTime let you format depending of the current culture. What are the culture supported by default? The scenario I have in mind use this.Date.Value.ToString("MMMM") which will print "January" if the culture is set to english-us but will print "Janvier" if the culture is in french-ca. This formatting documentation can be found at MSDN website but doesn't give the scope of culture this one can translate. I would like to know what languages are supported and if a language is not, what are my options? You can use CultureInfo.GetCultures to get all supported cultures. CultureInfo[] cultures =

.NET equivalent of choices in Java resource bundles?

只愿长相守 提交于 2019-12-06 02:57:21
In Java resource bundles I may have the following Resource Bundle definitions: en_GB - British English jobs.search.resultstr = There {1,choice,0#are no jobs|1#is one job|1<are {1,number,integer} jobs} for your search ceb_PH - Cebuano jobs.search.resultstr = Adunay {1,choice,0#mga walay mga|1#mao ang 1 nga|1<{1,number,integer}} trabaho alang sa {1,choice,0#inyong mga|1#imong|1<inyong mga} search The code I would use to extract the resource would make choices based on the input data and format the string correctly resulting in one of three different outputs. pseudo code: myResultStr =

How to refresh localized attributes in PropertyGrid

本小妞迷上赌 提交于 2019-12-06 00:23:16
I have problem with my localized attributes such as: public class LocalizedDisplayNameAttribute : DisplayNameAttribute { public LocalizedDisplayNameAttribute(string resourceId) : base(GetMessageFromResource(resourceId)) { } private static string GetMessageFromResource(string resourceId) { var propertyInfo = typeof(Lockit).GetProperty(resourceId, BindingFlags.Static | BindingFlags.Public); return (string)propertyInfo.GetValue(null, null); } } When I'm using properties with this attribute it's localized in PropertyGrid, but when I change the current CultureInfo it doesn't refresh, even if I

How do I combine resource strings for validation attribute error messages?

一曲冷凌霜 提交于 2019-12-06 00:02:24
问题 If I were to have error messages on a validation attribute like: First Name is required Last Name is required and then a validation attribute like this: [Required(ErrorMessageResourceName = "Error_FirstNameRequired", ErrorMessageResourceType = typeof(Strings)] public string FirstName {get;set;} I don't want to have a translation done for every instance of this. Is there a way to combine resource strings in a formatter, for example: [Required(ErrorMessage = string.Format("{0} {1}", Strings

Do we affect multiple users in ASP.NET when we set the Thread CurrentCulture/CurentUICulture?

好久不见. 提交于 2019-12-05 20:22:52
问题 When we set the CurrentCulture and/or CurrentUICulture we do this on the current thread like this: Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB"); Doest this mean we could affect the culture settings of multiple users of our web application as their requests may reuse the threads from pool? I am working on an ASP.NET MVC application where each user may have own culture setting specified in his/her account data.