Loading translation service classes from App_Code

Kentico EMS required

Features described on this page require the Kentico EMS license.

For translation services defined in the App_Code folder, you need to ensure that the system loads the appropriate class when calling the given service.

  1. Open your Kentico project in Visual Studio.

  2. Edit the App_Code class containing your translation service.

  3. Add a using statement for the CMS namespace:

    using CMS;
  4. Add the RegisterCustomClass attribute above the class declaration.

    Warning

    The following example loads the sample machine and human translation providers. An error will occur if you do not have the corresponding classes in your web project. You need to adjust the attribute parameters to match the names of your own custom service classes.

    [assembly: RegisterCustomClass("SampleMachineTS", typeof(SampleMachineTS))]
    [assembly: RegisterCustomClass("SampleTS", typeof(SampleTS))]

    The RegisterCustomClass attribute registers custom classes and makes them available in the system. The attribute accepts two parameters:

    • The first parameter is a string identifier representing the name of the class. The name must match the value of the Service provider - Class field specified for the given service in the system.
    • The second parameter specifies the type of the class as a System.Type object. When a user requests the translation service, the attribute ensures that the system gets an instance of the appropriate class and executes its methods.

You can now create your translation services in the Translation services application using the specified App_Code classes.