cultureinfo

Automapper Mapping for Localization Resolver in a Multi-Language Website

此生再无相见时 提交于 2019-12-22 12:05:11
问题 I found a way to use Automapper for Language mapping based on the active Culture. The question is if it's possible to build a generic Resolver to map all the models that use the Resolver. In this Case, the models to map have always the same properties, Id and Name (including the language properties Name_PT, Name_FR and Name_EN): // MODELS public class MakeDto { // Primary properties public int Id { get; set; } public string Name { get; set; } public string Name_PT { get; set; } public string

Entity Framework - SQL Server 2005 - IIS Server datetime issue

牧云@^-^@ 提交于 2019-12-22 09:38:21
问题 I'm working with MVC3 and Entity Framework. In my application I need to call a stored procedure in SQL Server 2005 via EF to search for some data according to datetime parameters passed. Everything seems to be working fine in local environment. But after hosting it into IIS I am getting an exception while trying to search from date 13-08-2012 (13 is taking as month in SQL I guess) Error says SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM I understood

Country name to ISO 3166-2 code

可紊 提交于 2019-12-22 05:37:08
问题 I know how to convert an ISO 3166-2 code to the full English name, e.g. "US" to "United States" by using RegionInfo . However, how can I do the opposite, i.e. that takes "United States" and returns "US"? 回答1: //Get the cultureinfo RegionInfo rInfo = new RegionInfo("us"); string s = rInfo.EnglishName; //Convert it back CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures); CultureInfo cInfo = cultures.FirstOrDefault(culture => new RegionInfo(culture.LCID).EnglishName

Culture is not supported

六眼飞鱼酱① 提交于 2019-12-22 03:43:42
问题 I'm using Visual Studio 2012 Ultimate version. I've got this error and I don't know how to solve it. Culture is not supported. Parameter name: name en-UK is an invalid culture identifier. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Globalization.CultureNotFoundException: Culture is not supported. Parameter name:

ToString(“0”) versus ToString(CultureInfo.InvariantCulture)

余生颓废 提交于 2019-12-22 03:24:07
问题 I would like to make sure that certain numbers in my application are printed without any separators, groupings etc. no matter what the current environment is. It seems that the following two methods produce the same results (there are possibly more): 123456789.ToString("0"); 123456789.ToString(CultureInfo.InvariantCulture); Are you aware of any edge cases or quirks? Which one is more "correct"? Which one would you use? I used to use the second one, but recently I found the first one and

.Net CultureInfo Month Names returning an extra empty string

空扰寡人 提交于 2019-12-21 07:15:45
问题 I have the following code to get a list of Month names: var monthNames = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames; For some reason, this keeps returning an additional empty string value along with the Month names: I am using Xamarin Studio. Anyone else encounter this before? 回答1: Some calendars like TaiwanLunisolarCalendar or KoreanLunisolarCalendar have 13 months. In a 12-month calendar, the 13th element of the array is an empty string. DateTimeFormatInfo

.Net CultureInfo Month Names returning an extra empty string

末鹿安然 提交于 2019-12-21 07:15:05
问题 I have the following code to get a list of Month names: var monthNames = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames; For some reason, this keeps returning an additional empty string value along with the Month names: I am using Xamarin Studio. Anyone else encounter this before? 回答1: Some calendars like TaiwanLunisolarCalendar or KoreanLunisolarCalendar have 13 months. In a 12-month calendar, the 13th element of the array is an empty string. DateTimeFormatInfo

Convert language abbreviation to full name, e.g. en to English?

筅森魡賤 提交于 2019-12-21 06:27:36
问题 quick question, what's the best way to convert language a abbreviation to full name? e.g. en to English? Note, it's not en-US, it's just en, fr, de C# please. 回答1: I'm not sure you can get it from just en... You can do this though if you know the rest of the abbrevation: System.Globalization.RegionInfo info = new System.Globalization.RegionInfo("en-GB"); string countryName = info.EnglishName; Edit: Actually, you can do it: CultureInfo info = new CultureInfo("en"); string englishName = info

How to get timezone from properties in CultureInfo

梦想与她 提交于 2019-12-20 18:44:32
问题 I have a string, which contains a timestamp ( yyyy-mm-dd hh:mm:ss ) . I can create a CultureInfo object based on other information I get. Therefore I know which country the timestamp is in. The timestamp is not in UTC/GMT. Say the timestamp is from Indonesia ( new CultureInfo("id-ID") ) , meaning the string was created by code below or similar. DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); That means the string contains the local time in Indonesia. I know my timezone, but I don't know how to

Localization resources not changing on certain hyperlink controls in a page

主宰稳场 提交于 2019-12-20 05:53:43
问题 Above is the screenshot of the site in development... We have a DropdownList control and on its SelectedIndexChanged it postbacks, and we then change the site culture and it then loads the respective resources files. DropDownList ASP.NET Code <asp:DropDownList ID="ddlLanguage" runat="server" CssClass="select-language" AutoPostBack="true"> <asp:ListItem Value="en-US" Text="English" title="/images/Flag_USA.gif"></asp:ListItem> <asp:ListItem Value="it-IT" Text="Italiano" title="/images/Flag