Localizing LightSpeed Messages
All of LightSpeed’s localizable resources such as error and validation messages are kept in a single resources file (Resources.resx). This file is made available as part of the LightSpeed installation and can be found in the Localization folder under the LightSpeed installation directory.
To localize LightSpeed messages, translate the messages in Resources.resx, build the translation into a satellite DLL and deploy the satellite DLL alongside your application. A sample illustrating how to produce and deployed a localized satellite resource assembly can be found in the Samples folder.
Localizing Property Names
Although you can localize messages such as validation messages via a satellite assembly, in some cases, specifically validation, these messages contain placeholders which LightSpeed will fill in with property names – that is, the same names you use in your code. Normally, as per the ‘ubiquitous language’ of domain driven development, you will use property names which are familiar to your users. But if you are serving users in multiple locales then you may need to display different property names in each locale, so you will have to convert from the .NET property names to localized display names.
To do this, create an implementation of the IDisplayNamingStrategy interface to perform the translation and return the translated name. Here is an example which simply looks up the property name in the application resources, allowing you to localize names through a satellite DLL.
Implementing IDisplayNamingStrategy |
public class ResourceLookupStrategy : IDisplayNamingStrategy |
To use this strategy, set LightSpeedContext.DisplayNamingStrategy in code, or the displayNamingStrategyClass attribute in configuration.
Specifying a display naming strategy in configuration |
<add name="Test" |
Specifying a display naming strategy in code |
_context.DisplayNamingStrategy = new ResourceLookupStrategy(); |