0

I would like to support English language for European formatted culture.

Dates should be displayed in English using European format. So, "14:00 Sunday, 16/July/2017" should be displayed and not the British way... Actually Irish culture is OK for this!

Further on, for example when I need to show currency, I would like it to be formatted as "1.500,00 €". Now, in order to support English language, if I use British culture I get the pound sign. If I use Irish culture I get "€1,500.00" which is not the standard way to format currency in Europe.

I would like at the present state of my application to support en-US and (if there was such a thing) en-EU. Any ideas? Do I need to create a custom culture? Any pointers?

1 Answers1

0

In our application, all DateTime objects are stored in UTC and converted to a proper representation by a helper method in our framework:

public static string ToString(DateTime? date, string format)
{
   if (date.HasValue)
      return String.Format("{0:}"+format, date);
   else return "";
}

where format is retrieved from our stored languages.

decimal properties representing currency are also converted by a helper method in our framework. For this, we use NumberFormatInfo:

        numberFormat = new NumberFormatInfo();
        numberFormat.CurrencyDecimalSeparator = ".";
        numberFormat.CurrencyGroupSeparator = "";
        numberFormat.NumberDecimalSeparator = ".";
        numberFormat.NumberGroupSeparator = "";

And then use the created NumberFormatInfo:

price.ToString(numberFormat);

The biggest advantage of this approach is that you can create your own preferences, despite what someone else thought of as logical and that these methods support custom user settings.

The drawback is that you, well, need to create languages and formats for every country you support.

CthenB
  • 800
  • 6
  • 17
  • Thank you for your answer. Still, even if I ask the user about his prefered way to display numbers and currency, there are problems with dates... In US, Thursday July 20, 2017, in EU Thursday, 20 July 2017. In US, 7:24 PM, in EU 19:24 (no PM, AM). Any ideas about those? –  Jul 20 '17 at 17:26
  • @Panos same solution, different technique. Include the format to use to display a date in a user's locale settings. It typically consists of 3 elements: 1. Display day of week, display abbreviation for day of week, no day of week. (Long date in excel) 2. Whether to display time in AM/PM, digital time or no time. 3. What format to display the date in (2017/07/13, 2017/13/07 or 13/07/2017. Combine these three string locale values into the proper .ToString() template value, and then simply pass that on to whatever methods converts dates to strings. – CthenB Jul 21 '17 at 16:50