Localization

The built-in localization mechanism in Silverlight and WPF allows you to localize any string resource used by the RadSpellChecker control. Once translated you might use your resources in both Silverlight and WPF projects without changing anything. You can find more information on the localization of the Telerik UI Suite here.

There are two ways to implement the localization - using Resource files or a custom localization manager.

Supported Languages

RadSpellChecker can be translated in one of the following supported languages using the framework’s localization mechanism:

  • English
  • German
  • Spanish
  • French
  • Italian
  • Dutch
  • Turkish

More information on how to achieve this you can find in the Localization Using Built-in Resources article.

Localization Using Resource Files

You can base your localization on the standard resource files provided by the .NET framework. For that purpose you will have to create a separate .ResX file for each one of the languages that your application will support. Imagine that you want to translate your application into English, German and Dutch. In that regard, you will have to add three new resource files to your project:

  • RadSpellChecker.resx - this resource file will store the English (default) resources for the spell-checker control. Set the AccessModifier property to Public.

  • RadSpellChecker.de.resx - this resource file will store the German resources for the spell-checker control. Set the AccessModifier property to No code generation.

  • RadSpellChecker.nl.resx - this resource file will store the Dutch resources for the spell-checker control. Set the AccessModifier property to No code generation.

Here is the complete list of RadSpellChecker-related Resource Keys, which you should include in each of the resource files:

  • Documents_SpellCheckingDialog_Header

  • Documents_SpellCheckingDialog_NotInDictionary

  • Documents_SpellCheckingDialog_IgnoreAll

  • Documents_SpellCheckingDialog_AddToDictionary

  • Documents_SpellCheckingDialog_ChangeTo

  • Documents_SpellCheckingDialog_Change

  • Documents_SpellCheckingDialog_Suggestions

  • Documents_SpellCheckingDialog_EditCustomDictionary

  • Documents_SpellCheckingDialog_SpellingCheckIsComplete

  • Ok

  • Cancel

  • SpellChecker_SpellingCheckIsCompleteMessageHeader

  • SpellChecker_SpellingCheckIsCompleteMessage

  • Documents_EditCustomDictionaryDialog_Header

  • Documents_EditCustomDictionaryDialog_Word

  • Documents_EditCustomDictionaryDialog_Dictionary

  • Documents_EditCustomDictionaryDialog_Add

  • Documents_EditCustomDictionaryDialog_Delete

  • Documents_EditCustomDictionaryDialog_DeleteAll

  • Documents_EditCustomDictionaryDialog_DeleteAllMessageHeader

  • Documents_EditCustomDictionaryDialog_DeleteAllMessage

  • Close

The three files should keep the same resource keys, whereas the values must be the translated ones.

The last step is to instantiate the LocalizationManager class and set its ResourceManager to the resources that have been just created.

LocalizationManager.Manager = new LocalizationManager() 
{ 
   ResourceManager = RadSpellCheckerResources.ResourceManager 
}; 

If you rely on culture settings to load the right resources automatically, you have to write some code inside your application's project file. For example, if you have to support English and Dutch languages, you can store the localized strings in Resources.resx and Resources.nl.resx files. For the Resources.resx file you can set ResXFileCodeGenerator to Internal or Public and for others to No code generation. Then, open the project file in a text-mode and insert the code below into the section. In this way you notify the framework about the supported cultures.

<SupportedCultures>en;nl</SupportedCultures> 

Localization Using Custom Localization Manager

Telerik.Windows.Controls.LocalizationManager allows you to easily localize any of the Telerik controls. To apply custom localization to your controls, just instantiate your custom LocalizationManager deriving from the LocalizationManager object and set it to the static property LocalizationManager.Manager before the creation of the UI.

LocalizationManager.Manager = new CustomLocalizationManager(); 

Note that if you set the localization manager after the creation of the UI, some parts might remain not-localized.

What is left in order to fulfil the localization is to override the method GetStringOverride(). The logic is pretty simple, you just have to create a switch statement and return the correct translation for each resource key. Here is an example of how you can localize some of the strings in the two SpellCheckingDialogs:

public class CustomLocalizationManager : LocalizationManager 
{ 
   public override string GetStringOverride(string key) 
   { 
       switch(key) 
       { 
           case "Documents_SpellCheckingDialog_Header": 
               return "New Header"; 
           case "Documents_SpellCheckingDialog_NotInDictionary": 
               return "New NotInDictionary Notification"; 
           case "Documents_SpellCheckingDialog_IgnoreAll": 
               return "New Ignore All"; 
           case "Documents_SpellCheckingDialog_AddToDictionary": 
               return "New Add to Dictionary"; 
           case "Documents_SpellCheckingDialog_ChangeTo": 
               return "New Change to";  
           case "Documents_SpellCheckingDialog_Change": 
               return "New Change"; 
           case "Documents_SpellCheckingDialog_Suggestions": 
               return "New Suggestions"; 
           case "Documents_SpellCheckingDialog_EditCustomDictionary": 
               return "New Show EditCustomDictionary"; 
       } 
       return base.GetStringOverride(key); 
   } 
} 

Of course, if you don't want to hard-code your translation inside the source code, you can always use resource files:

public override string GetStringOverride(string key) 
{ 
   switch( key ) 
   { 
       //---------------------- 
       case "Documents_SpellCheckingDialog_Header": 
           return MyRadSpellcheckerResources.Documents_SpellCheckingDialog_Header; 
       //---------------------- 
   } 
   return base.GetStringOverride(key); 
} 
In this article