I need help to choice logic decision for implementing translation some fields of entity.
I have:
Product {
String title;
String manufacturer;
String productType;
// e.t.c.
}
- Several different DTOs - used for interaction with UI and services
ProductUIDto {
String title;
//...
}
NotifyDto {
String productTitle;
String someLocalizedField;
//...
}
PrintDto {
String productTitle;
String someLocalizedField;
//....
}
The existing implementation contains some localization logic.
Translations ones fields stored in DB, another (types etc.. - static data) - in resource files, translations of thirds - we compute by own algorithms.
So, for each DTO we have mapper-converter, which our Product Entity converts to it.
ProductUIConverter {
LocalizationServise l10nService;
ProductUIDto convert(Product product) {
ProductUIDto dto = new ProductUIDto();
dto.title = l10nService.translateTitle(product.title);
//... for all fields, needs to be translated we get transation from LocalizationServise
}
}
So, we have tens "smart" converters. When we get a task to localize new property - we implements logic in l10n service (new method) and add execution it in each converter.
Is it a problem or not, that our converters were involved in localization logic?
How we can (if should) to distinct this logic from mapping correctly?
Thanks a lot!
question from:
https://stackoverflow.com/questions/65949542/clear-architecture-for-implementation-translation-needs 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…