You can use Haiilo's API to assign a specific language to a user. By default, the platform appears in a default language for all users until they select their preferred language in their account settings. However, when operating in moderator mode, you can set a user's language using the API. This feature can be particularly useful if you want users to view the platform in a language different from the default when they log in for the first time.
You need to authenticate first to make calls to the Haiilo API. Additionally, to change a user's language, you must be in moderator mode when making the API call. You can find detailed information about authenticating and using the API in our API documentation.
List all activated languages
First, obtain a list of your activated languages and their language identifiers using the API call below.
- Make a GET request to the endpoint
/api/languages.
The response should look like below if you've activated English, German, and French:
[
{
"language": "DE",
"active": true,
"defaultLanguage": false
},
{
"language": "EN",
"active": true,
"defaultLanguage": true
},
{
"language": "FR",
"active": true,
"defaultLanguage": false
}
]
Set a user's language
Then, assign a language to a user using the API call provided below.
- Start a new request.
- Copy a language identifier from the response for activated languages. You can only set a language that has already been activated on the platform.
- Enter the below in the request body:
{
"language" : "<language_identifier>" /* E.g., DE for German */
} - Make a PUT request to the endpoint
/api/users/<user_id>/languagewhere<user_id>is the ID of the user you're updating.
After a successful response, the user's language is changed. To update the language for multiple users at once via the API, you can develop a script.