I am about to start on a project which must support a number of European languages. All static content on this site must be translatable between these languages. I have heard of satellite assemblies and have heard that they are used for multi-language sites in .NET but this was a long time ago. Is this still current practice in .NET? I'm using ASP.NET MVC.
If you're using ASP.NET MVC, one option would be to use a different resource for each view. I wrote an article about it, maybe it can be of help:
ASP.NET MVC Localization: Generate resource files and localized views using custom templates
Without the satellite part, you can add a App_GlobalResources
folder to the project and add *.resx
files for each language. You can have one resource file for the whole project, or one per ASP.NET MVC Area or however you see fit, but you don't need to have more then 1.
App_GlobalResources
MyResources.resx (Neutral / Default language translated texts)
MyResources.en-GB.resx
MyResources.de-DE.resx
In MyResources.resx
Name Value
TextID Some text which will be localized to the end user.
In Global.asax.cs (Application_PreRequestHandlerExecute
)
// Set it according to cookies/Session etc.
System.Threading.Thread.CurrentThread.CurrentUICulture = "de-DE";
System.Threading.Thread.CurrentThread.CurrentCulture = "de-DE";
Then in the Views and PartialViews (e.g. MyView.cshtml).
<span>@Resources.MyResources.TextID</span>
Optional:
The Resources can be added as a link, and use custom namespaces.
BuildAction: Embedded Resource
CopyToOutputDirectory: Copy always
CustomTool: PublicResXFileCodeGenerator
CustomToolNamespace: MyNamespaceHere
mToolNamespace: MyNamespaceHere
Then they would be accessible via.
<span>@MyNamespaceHere.MyResources.TextID</span>
This is a general way to use (normal / linked) resources in ASP.NET MVC. If you use "Add as link" you can have one physical copy in a separate project.
Satellite:
Some info on satellite assemblies:
MSDN: Creating Satellite Assemblies
A MSDN Blog: Introduction to Satellite Assemblies
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With