The application I have uses localization. The way it is built, is that it examines an entity (traversing down the structure) and translates every property marked as ‘translate’.
The translations are stored in separate translation tables.
This is all fine but it leaves me with the problem that I now get the translated values in my ‘default’ values when I update the entity using the translations. And I don’t want that.
Let me try and explain better.
Database:
The mapping of footprintlinevLue:
public class FootprintLineValueMap : ClassMap<FootprintLineValue> {
public FootprintLineValueMap() {
Table("FootprintLineValue");
Id(x => x.Id).GeneratedBy.Identity().Column("Id");
References(x => x.FootprintLine).Column("FootprintLineId");
References(x => x.CategoryValue).Column("CategoryValueId").Cascade.None();
}
As you can see a footprintline has multiple values that reference a categoryValue. The categoryvalue is localized.
When I now retrieve footprintlines our framework will put it through our translationservice and will automatically translate the Name and Description of the CategoryValue in the corresponding culture. If it cant find a translation in CategoryValueLocal, it will use the default in CategoryValue.
However…if I save a Footprintline, it will save the translated values back into CategoryValue (overwriting the default) instead of ignore it.
CategoryValues are not value objects and could be changed so I cant make them readonly.
I tried to map the reference as Cascade.None, but that doesn’t seem to do anything.
I hope there is a way to simply mark this in the mapping so we can keep on using our TranslationService instead of having to figure out another way to hande localization.
mark the properties as not updateable.
you could even define a convention to do so