Should Localization Ever Be Part of Domain or Business Logic?
Asked by
MellowPine42
I was taught that localization should stay limited to the presentation layer, but I'm wondering how this works in real applications. Do developers ever use locale or language data inside core business logic, or should the domain remain completely independent of how information is displayed?
Answers
There can be an exception when the domain itself is fundamentally tied to a particular language. Some industries use specialized terms that do not translate cleanly, so modeling those concepts in the language used by the subject-matter experts can be practical. That is more about choosing the domainโs terminology than ordinary UI localization.
Reply to this answer
A good separation is for the domain to return structured results, error codes, or validation keys, while the UI or document-generation layer turns those into localized text. That keeps translations from being scattered through service code and makes adding another language much easier.
Reply to this answer
Localization should generally stay at the presentation boundary. If the core logic starts depending on values like โen-USโ or translated strings, changing languages can unexpectedly affect business behavior and make testing much harder. For rules involving geography, taxes, or compliance, use an explicit country code, region, or domain-specific enum instead of the userโs display locale.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions