I'm trying Castle.AR in an ASP.NET MVC 1 app. I want to store localized content on db.
I'm thinking of creating a single table with int stringId, string locale, string text
, and all other tables with int fields instead of strings.
[ActiveRecord]
public class LocalString : ActiveRecordBase<LocalString>
{
[PrimaryKey]
public int Id { get; set; }
[Property]
public int StringId { get; set; }
[Property]
public string LocaleName {get; set; }
[Property(ColumnType = "StringClob")]
public string Text { get; set; }
}
public class Category : ActiveRecordBase<Category>
{
[PrimaryKey]
public int Id { get; set; }
[Property]
public int NameId { get; set; }
[Property]
public int DescriptionId { get; set; }
}
...
Is there a better syntax than this, to make ActiveRecord do part (or all) of the work of storing and retrieving the right localized strings for me?
If not, how could I generalize the work so that I don't have to repeat the same code for each field of each class?
Edit
Two other features would be required:
strings should be eagerly loaded with each record (that is, when I find a Category, its name and description for current locale should be loaded as well);
if the right translation is not available, the best one among UserLanguages or a default one should be presented.