1

I am creating a web application which needs to be hosted in France. With French regional settings, server collation and local timezone.

The main issue I am facing is the number format. In European/French styles the number format uses comma(,), instead of dot(.) for the decimal separator(Eg: 12,53(French) = 12.53 (US)). My development environment is following US culture.

What are the things to take care on server settings to handle this.

On SQL server it is storing dot(.) always, but I have to display comma(,) on screen.

How do I handle this.

Scath
  • 3,777
  • 10
  • 29
  • 40
George Thomas
  • 125
  • 2
  • 12
  • 1
    Do you plan to convert each thing you display to string before you give it to your webapp? if so, you can use the french culture when stringifying it - but thats plenty of risky / errorprone outputs. Probably better: set the used culture for your web app to fr-FR, be carefull when parsing inputs from users to convert it into invariant numbers/dates and accept only fr-FR validateable inputs. When outputting, use converters aware of fr-FR to display it as fr-FR needs it. All in all - a broad topic .... – Patrick Artner Apr 12 '18 at 06:04

2 Answers2

1

In your code before you are to format the data (Numbers/Dates/Currency etc) -- First, get the Current Culture Info.

Then use the Data Specific Format to format your string into Culture relevant string.

Prateek Shrivastava
  • 1,877
  • 1
  • 10
  • 17
  • I am using some formulas in my application, eg: round(x,y).. it would have worked in normal decimal eg round (6.35898,3).. But in French locale, while storing it's stored as round (6,35898,3).. Which invalidates the expression. Also SQL server is storing numeric values using Dots as precision/scale separator, when do a select using Entity framework, I am getting Dots, instead of comma. – George Thomas Apr 16 '18 at 06:43
0

You can achieve this by below ways:

Store data with dot(.) as decimal separator in database and at the time of retrieval you can convert the value into string and replace dot(.) with comma(,). For example,

string doubleValue=valueFromDatabase.ToString("0.00");
doubleValue=doubleValue.replace('.',',');

You can also use varchar format. so you can store data with comma(,) as decimal separator and retrieve directly from database. You can provide client side validations for accepting data in required format.

Techno Crave
  • 423
  • 1
  • 7
  • 17
  • I am using some formulas in my application, eg: round(x,y).. it would have worked in normal decimal eg round (6.35898,3).. But in French locale, while storing it's stored as round (6,35898,3).. Which invalidates the expression. Also SQL server is storing numeric values using Dots as precision/scale separator, when do a select using Entity framework, I am getting Dots, instead of comma. – George Thomas Apr 16 '18 at 06:43
  • @GeorgeThomas You don't need to perform mathematical operation in French locale, perform operation in normal decimal and then convert it into string and store as french locale in db. At the time of retrieval again replace comma(,) with dot(.) and convert it into double type after that you can perform operation. – Techno Crave Apr 16 '18 at 09:10