我正在尝试使用 Onion Architecture 学习 DDD,但遇到了一个问题
我的应用程序应该支持标签、枚举、验证消息和某些实体中的某些数据(例如 Item.ItemName)
的本地化因此,很明显本地化过程与域和 ui
这个本地化服务也应该支持缓存
现在我很困惑我应该把这个类放在哪里
1 回答
I didn't do localization with DDD approach yet, but I'll try my best to help you.
Localization is a matter of presentation data, I don't think that your domain model should be concerned about it, if its only purpose is presentation. So how to handle it?
This is how I would do it.
Let's say that client is creating new product. Of course he has to define a name for it. You want every product name to be translated to different languages. It's your choice how you will do it:
- admin panel for every product
- client has to provide it while creating new product
- dictionary
- mix of all of these
etc. it doesn't really matter.
So in Your createNewProduct
view you should call product service that will create new product and also call some service that will create translations for that product, but don't save translations in domain entity. In other words you should separate services for handling business logic and for creating translations. Then just link them by productId when presenting.