I'm trying to get a resource value for internazionalization based on the value of an foreach variable.
My resource project is named Resources, I reference this on my main project.
When i want to use it. only use something like this: Resources.resourceKey
The Problem
Now I need to use this but resourceKey is in a variable on a loop
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => Resources.item.Rating)
</td>
</tr>
}
This obviusly not working, in Resources has no exists any key named item
My solution (Not working)
Create a Resource Manager and try to get a string
@{
System.Reflection.Assembly resourcesAssembly;
resourcesAssembly = System.Reflection.Assembly.Load("Resources");
System.Resources.ResourceManager rm = new
System.Resources.ResourceManager(resourcesAssembly.FullName,
resourcesAssembly);
}
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => rm.GetString(item.Rating))
</td>
</tr>
}
What i'm doing wrong??
Really thnx for help