如何使用可更新与外语词的处理 [英] How to Deal with Updatable Languages and Their Words
问题描述
我对多语言两个数据库表在我的项目:
I have two database tables for multilinguality in my project:
Word -ID- -En- -Ge-
1 Hello Hallo
2 Yes Ja
Lang -ID- -Name- -FlagFileName-
1 English flag-en.jpg
2 Deutsch flag-ge.jpg
不过,我需要能够以新的语言添加到系统中。我可以添加一个新行郎表和新列字表,但我不能更新我的ASP.NET MVC3项目的DbContext对象。我的数据库对象在我的模型。
But, I need to be able to add new languages into the system. I can add a new row to Lang table and a new column to Word table, but I cannot update the DBContext object in my ASP.NET MVC3 project. My DB Objects in my Model.
public class Word
{
public int ID { get; set; }
public string English { get; set; }
public string Deutsch { get; set; }
}
public class Language
{
public int ID { get; set; }
public string Name { get; set; }
public string ImageFileName { get; set; }
}
我需要一种方法来定义Word作为新的语言可以被添加到它。如何更新Word对象?这是甚至在某些方面是可行的?
I need a way to define Word as new languages can be added to it. How can I update the Word object? Is this even doable in some way?
我也有处理动态浏览的问题:
I also have problems dealing with dynamic Views:
@{
Type objectType = Type.GetType(typeof(MyProjectNamespace.Models.Word).AssemblyQualifiedName);
System.Reflection.PropertyInfo[] fields = objectType.GetProperties();
}
<table>
@foreach (System.Reflection.PropertyInfo f in fields)
{
<th> @f.Name.ToString() </th>
}
@foreach (var item in Model) {
<tr>
@foreach (System.Reflection.PropertyInfo f in fields)
{
<td>@Html.DisplayFor(modelItem => item.English)</td>
<td>@Html.DisplayFor(modelItem => item.Deutsch)</td>
<td>//How can I display for a new Language here?</td>
}
</tr>
}
</table>
我可以得到的Word的每个属性并打印出它们与下面的code头文件,但我怎么能在这些动态属性打印值?这是可行的?
I can get every attribute of Word and print out them as Headers with the code below, but how can I print the values in these dynamic attributes? Is this doable?
我AP preciate任何想法,我甚至准备重新创建表。
I appreciate any ideas, I am even ready to recreate tables.
推荐答案
我决定去简单。这也许是可行的,但不值得,处理动态模型对象,并得到他们的动态属性。所以,我决定我需要一个Word表格如下:
I decided to go simple. It's maybe doable, but not worth it, to deal with dynamic Model objects and get their dynamic attributes. So I decided I need a Word table like:
Lang -ID- -Name- -FlagFileName-
1 English flag-en.jpg
2 Deutsch flag-ge.jpg
Word -ID- -Text- -LanguageID-
1 Hallo 2
2 Hello 1
3 Yes 1
4 Ja 2
由于词不会在数学指数站在新的语言被加入,例如:
As the Words won't be standing in a mathematical index as new languages are added such as:
--indexed-- --index broken--
1-English Word 1-English Word
2-German Word 2-German Word
3-English Word 3-Spanish Word
4-German Word 4-Dutch Word
和计算机无法理解与100%可靠性的词的意思,我决定举办一个含义表,其中仅持有英文单词:
And the computers cannot understand the meaning of a word with %100 reliability, I decided to hold a Meaning table, which only holds English words:
Meaning -ID- -Text-
1 Hello
2 Yes
和实际结合词的含义是:
And bind the meanings with actual Words:
Word -ID- -Text- -LanguageID- -MeaningID-
1 Hallo 2 1
2 Hello 1 1
3 Yes 1 2
4 Ja 2 2
我被分配的wordID对新的动态元素,如一种新型的,这将被用于某处填充下拉框。现在,我将其绑定到MeaningID。
I was assigning WordID's to new dynamic elements, such as "a new type", which will be used to fill a dropdown box somewhere. Now I'll bind it to a MeaningID.
此解决方案是明确的,易于理解和易于实施的,我猜。我不会接受我自己的答案了一个星期,在某些情况下,解决方案,明确可能psented以我目前的表$ P $。
This solution is clear, understandable and easily-implementable, I guess. I won't accept my own answer for a week, in case some clear solutions might be presented to my current tables.
这篇关于如何使用可更新与外语词的处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!