Enabling Language Support for Android SDK(Legacy)
If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.
- Getting Started
- IVA Building Guides
- Conversation Design
- Developer Guides
- Agent Setup
- Analytics & Reporting
- Tips & Tricks
Table of ContentsOverviewGuidelinesConfiguring Language SupportChanging the language of the SDK with language of the appChecking the language preference set by the userExpected SDK behaviour with Language Support
Language support is by default enabled in the Haptik SDK. The default language set in the SDK would be English "en".
Language support will enable multi-lingual bot support in the SDK. Users will get a choice to choose from a list of languages supported for the bot.
The language preference for the user should be specified using language codes that conform to the ISO 639-1 code. For example "en" for English
Any other string input then can lead to unexpected behavior during language switch.
Use this configuration to set a language preference on the Haptik SDK.
You can set the language preference in InitData using the method
After adding the language preference InitData should like below
InitData initData = new InitData.Builder(Application application) .baseUrl(String string) .debugEnabled(boolean debugEnabled) .notificationSound(int soundResource) .languagePreference(String languagePreference) .build();
NOTE: The language passed should conform to ISO 639 - 1 convention for example: pass "hi" for Hindi, pass "en" for English.
Apart from InitData, the parent app can change the language preference of the SDK using the
Haptiklib.updateUserLanguagePreference(String languagePreference, final Callback<String> updateLanguageCallback);
It is recommended to make this method call every time there is a language change in the parent app.
This is a network call, please make sure to check the availability of the network before making this call.
In case this call fails, the language preference of the user is not updated.
Apart from configuring the language support for the app, while initializing the SDK and changing the language preference at runtime as mentioned above, the user can also change the language preference in the SDK.
User can change the language preference from the messaging activity. This will be persisted by the SDK.
You can access the language preference set by the user in the SDK using
This method returns the user's language preference as String, conforming to ISO 639-1 code.
Recommendation: You can access this function before initializing the Haptik SDK to get the language preference set by the user set in the previous session.
This can then be passed to the InitData in order to maintain a consistent user experience in terms of language preference.
String userLanguagePreference = HaptikLib.getUserLanguagePreference(Context context); InitData initData = new InitData.Builder(Application application) .baseUrl(String string) .debugEnabled(boolean debugEnabled) .notificationSound(int soundResource) .languagePreference(String languagePreference) .build();
The SDK treats messages in two different languages as separate conversations.
Consider, a user chatting in Hindi as well as English. The conversation history for hindi and english will be maintained separately.