0

I have a website for international users. Let's say the website supports English users only ( All texts on the website are English words ). The website has a submit form that the end-users of the website need to enter Dates, Integers, and Decimals. At server side, I will convert all the text-based fields: Date, Integer, and Decimals to Date, Integer, Double objects.

My question is: What kind of Locale I should use to convert all text-based fields to Date, Integer, Double objects at Server side?

I have 2 choices: The first choice is I will always use US-Locale for the conversions. The second choice is I will use the end-user browsers setting locales (From request locales).

If I use the first choice, let's say the French, Japanese, … etc. users must always enter US Locale Date, Integer, Decimals formats.

If I use the second choice, the French users can enter French Locale Date, Integer, Decimals formats, the Japanese users can enter Japanese Locale Date, Integer, Decimals formats, … etc.

I know each of choice has its own pros an cons. but I would like to know which choice is recommended.

Thanks!

4
  • 1
    This almost feels like more of a UI/UX problem, as whatever you decide in terms of parsing/conversion, you'll have a harder time getting the users to understand what to expect than on the conversions themselves. – Graham Oct 22 '20 at 20:26
  • 2
    Most UIs provide a calendar control to let users pick the date. The calendar controls usually can be easily configured to present the dates localized. – πάντα ῥεῖ Oct 22 '20 at 20:41
  • 1
    This is a requirements question. What formats do your users need? – joshp Oct 22 '20 at 21:06
  • 1
    Which “English”? British, US? They have different date formats. – gnasher729 Oct 23 '20 at 7:45
3

Generally I recommend that client should only send data in standardized format like ISO8601 or JSON-compatible number formats.

The UI can then present a date or number selector in locale sensitive format. Generally conversions should happen on the client side, although there are certain situations where server side conversions are more practical if you have multiple client apps and you need all of them to present a consistent conversion. However, in most cases Locale-sensitive formatting should generally be a client side concern.

2
  • Thank you for your great answer! – Loc Oct 23 '20 at 2:31
  • 1
    Should locale be determined by page language or by browser settings? The original question is about user input and not about transfer format. – Basilevs Oct 23 '20 at 5:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.