Should Localization Be Part of Domain or Business Logic?
Asked by
MellowCedar42
I was taught that localization belongs strictly in the presentation layer, but I'm curious how this works in real-world applications. Do developers ever use locale or language data directly in core domain or business logic, or should that logic remain completely independent of how information is displayed?
Answers
Putting localized strings deep in the service layer usually creates unnecessary coupling. Adding a language or changing a translation can unexpectedly affect core behavior and make testing much harder. For validation and error handling, the business layer can return stable error codes or structured results, and the presentation layer can translate those into user-facing messages.
Reply to this answer
There can be an unusual exception when the domain itself is inherently tied to a particular language. Some fields, legal concepts, or healthcare terminology may be most accurately modeled in the language used by the professionals and users of that domain. That is more about choosing the domainโs vocabulary than about localizing output, though, so it should be treated differently from ordinary presentation localization.
Reply to this answer
In most cases, keep localization at the edges of the application, such as the UI, document generation, or other presentation code. The domain should describe what the system does without depending on translated strings or locale identifiers. If business rules depend on geographyโfor example, taxes or regulatory requirementsโmodel that using a country code, region, or another domain-specific value rather than a display locale like โen-USโ.
Reply to this answer
Add your answer
Answers are reviewed before publication.
MellowCedar42: That distinction makes sense. So the key question is whether language is part of the domain concept itself, rather than merely the way the application displays a concept.