Object Oriented business logic with localization string?
Is it okay to have singleton inside Business Logic object to have localization string?
I cannot find any pattern about how to handle message from Business Logic in the good language of my user. Is it fine to have localization string inside? Is it better to just send back those properties Constant and later convert them into a localized string?
I would like to know what is the best practice please.
(I am asking because I want to have good unit tests don开发者_运维知识库e with this project and having a singleton each time I need to send a message from those Business object seem wrong...)
Strings should be stored in resourcefiles, so it supports more languages. And as Thomasz Nurkiewicz states above, string handling - and localization - should not be done by business logic, but by the presentation layer.
Bottom line: 1) Select a default language 2) Move all strings to resource files 3) Make resource files for any language you want to 4) Move string handling out of business logic.
Regards, Morten
精彩评论