Skip to main content
3 of 3
expanded example to demonstrate the depth of the answer versus the inefficiency/overhead of the alternative

Approach 1 – handling formatting in the frontend – is usually the best answer, as once something has been formatted it is less suitable for further processing. If there are multiple consumers in different cultures it is more natural to handle that closer to the point of use. It also saves you having to pass the culture back up to the API, and consequently simplifies the test coverage.

However, in some cases you are obliged to use the other approach (localization in the backend). For example, sorting and pagination - what constitutes "alphabetical order" is culture-dependent, which would appear is, say, the selection of sort order in an SQL query so that the cursor is in the user's culture-appropriate sort order (so that results can be incrementally returned by the cursor, instead of all results returned to the front end, then have the front end reorder all results).

pjc50
  • 15.3k
  • 1
  • 37
  • 40