I used the special .NET folder App_LocalResources
.
Here are the steps
Add the .resx
files to that folder (i.e.: Resource.resx
, Resource.es-ES.resx
)
Right click on each .resx
file and select properties
and make sure the following are selected
Build Action: Embedded Resource
Custom Tool: PublicResXFileCodeGenerator
Custom Tool Namespace: Resources
Then in your view you can use the Resources
name space to access the text in your .resx
file
<h2>@Resources.Resource.Global_Title<h2>
@Resources
because that is the name that you gave in the Custom Tool Namespace
and .Resource
because that is the name of the .resx
file
Also make sure that the resources are set to Public
To access the resources from any model just add a single line
using Resources; //<<-- This line
namespace Concordia_CRM.Models
{
public class SolicitudDemo
{
[Required]
[Display(Name = "SD_NombreEmpresa", ResourceType = typeof(Resource))]
public string NombreEmpresa { get; set; }
...
}
More details can be found on this post.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…