The localization module contains settings that allow the assistant to display messages sent via the chatbot in different languages. With these settings, chatbot messages can be delivered to the user in the target language.
Localization Menu
The localization menu can be accessed via Assistant > Localization. Using this menu, localization keys and their corresponding values in different languages can be defined.
Using Localization Keys
In the project, the Localization class is used to retrieve the value of a localization key.
Usage Example
Below is an example of how to retrieve the value of a localization key:
using QSoft.CxPerium.Dialogs.WhatsApp;
using QSoft.CxPerium.Models;
using QSoft.CxPerium.WhatsApp;
namespace QSoft.CxPerium.Assistant.Dialogs
{
public class MainDialog : WelcomeDialog
{
public override void RunDialog()
{
string message = this.Localization.GetLocalizationText(“SessionTimeoutMessage”);
}
}
}
Translating Text by Language
If you want to translate a text into a specific language, the GetLocalizationTextByLanguage method can be used.
Usage Example
string message = Localization.GetLocalizationTextByLanguage(“SessionTimeoutMessage”, LanguagesEnum.Turkish);
Note
- LanguagesEnum: Represents the target language. Supported languages are defined in this enum.
- If an unsupported language is selected, a NotImplementedException error is thrown.
Explanation
- Localization.GetLocalizationText(key):
- The
key
parameter represents a key defined in the localization file. In this example, the value of the key “SessionTimeoutMessage” is retrieved.
- The
- In the code, the localization system fetches the translated text value of the key and prepares it to be sent as a message to the user.
Note
Localization messages are determined based on the language setting of the detected dialogue from the user’s message.
This module is designed to facilitate chatbot developers in providing multi-language support.