LocalizationHelper Class

Provides members to localize Windows Forms controls and other objects. The ApplyStringResources method is automatically called by BaseForm and BaseUserControl instances if their DynamicStringLocalization property is set to a non-default value. The LocalizationRequested event can be handled to redirect the localization requests to a custom resource manager, or to set the value for a given key programmatically.

See the online help of the BaseForm.DynamicStringLocalization property for an example.

Definition

Namespace: KGySoft.WinForms
Assembly: KGySoft.WinForms (in KGySoft.WinForms.dll) Version: 5.0.1
C#
public static class LocalizationHelper
Inheritance
Object    LocalizationHelper

Methods

ApplyStringResources Applies string resources to the specified control and its children recursively. Invokes the LocalizationRequested event for each localizable property of the control and its children.
GetResourceBaseName(Assembly) Gets the base name of the resource file for the specified assembly. That is, the name of the resource file without the culture name and the .resx extension.
GetResourceBaseName(Type) Gets the base name of the resource file for the specified type. That is, the name of the resource file without the culture name and the .resx extension.
GetResourceSet Gets a resource set for the specified context if available. The result can be freely edited.
GetString(String, LocalizationContext) Gets a localized string for the specified key using the specified context. It invokes the LocalizationRequested event to retrieve the string resource. If the event is not handled, and a resource set is available for the specified context, it retrieves the string from that resource set.
GetString(String, LocalizationContext, Object) Gets a localized string for the specified key using the specified context and formatting arguments. It invokes the LocalizationRequested event to retrieve the string resource format. If the event is not handled, and a resource set is available for the specified context, it retrieves the string from that resource set.
GetString(CultureInfo, String, LocalizationContext, Object) Gets a localized string for the specified key using the specified formattingCulture, context and formatting arguments. It invokes the LocalizationRequested event to retrieve the string resource format. If the event is not handled, and a resource set is available for the specified context, it retrieves the string from that resource set.
LocalizeStringProperties Localizes the localizable string properties of the specified target object, using the specified name as a prefix for the resource keys.
ReleaseAllScopedResources Releases the loaded resource sets of all scoped resources. Resource sets will be reloaded on the next request. Can be useful after calling GetResourceSet if the result was edited and the changes should be discarded.
SavePendingScopedResources Saves all pending scoped resources to the corresponding resource files. Can be useful after calling GetResourceSet if the result was edited.

Events

LocalizationRequested Occurs when the localization of a string is requested. Can be used to redirect the localization requests to a custom resource manager, or to set the value for a given key programmatically.

See Also