Multiple Languages
Thursday, January 28, 2021 1:49 AMTable of Contents
All TalkJS UIs can be localized so that everything is displayed in the user's own language.
There are two ways to set the language in TalkJS. The default UI language is American English (en-US
). If the majority of your users use a language other than English, you can change the default language in the Dashboard.
If you need to support multiple languages at once, you can set the locale
field per user. The locale
field expects an IETF language tag.
Right-to-left Languages
If your app is right-to-left and you use the dir
attribute in your <html>
tag (eg <html dir="rtl">
), then TalkJS is automatically shown in right-to-left mode. Otherwise, set the dir
option in ChatboxOptions and InboxOptions to "rtl"
and everything will work as expected.
Additionally, TalkJS automatically defaults to a right-to-left layout when a right-to-left language is selected.
East-Asian Languages
If your language is commonly entered using an on-screen keyboard for character selection, you might find that TalkJS's behavior to automatically send messages on "enter" conflicts with character selection. A pragmatic workaround for this is to set enterSendsMessage to false
in createInbox's messageField
option.
Examples
Using the JS SDK
const me = new Talk.User({
id: "123456",
name: "Alice",
email: "[email protected]",
photoUrl: "https://demo.talkjs.com/img/alice.jpg",
welcomeMessage: "Hey there! How are you? :-)",
locale: "nl-NL" // <-- that's the one!
});
var me = new Talk.User({
id: "123456",
name: "Alice",
email: "[email protected]",
photoUrl: "https://demo.talkjs.com/img/alice.jpg",
welcomeMessage: "Hey there! How are you? :-)",
locale: "nl-NL" // <-- that's the one!
});
Using the REST API
PUT https://api.talkjs.com/v1/YOUR_APP_ID/users/12345
{
"name": "Alice",
"email": ["[email protected]"],
"photoUrl": "https://demo.talkjs.com/img/alice.jpg",
"welcomeMessage": "Hey there! How are you? :-)",
"locale": "nl-NL"
}
Currently available languages
- Albanian (
sq-AL
) - Arabic (
ar
) (with right-to-left UI layout) - Bulgarian (
bg-BG
) - Bosnian (
bs-BA
) - Chinese (Simplified) (
zh-CN
) - Chinese (Traditional) (
zh-TW
) - Czech (
cs-CZ
) - Croatian (
hr-HR
) - Danish (
da-DK
) - Dutch (
nl-NL
) - English (U.S.) (
en-US
) - Estonian (
ee-ET
) - Finnish (
fi-FI
) - French (
fr-FR
) - Hebrew (
he-IL
) (with right-to-left UI layout) - Hindi (
hi-IN
) - Hungarian (
hu-HU
) - German (
de-DE
) - Greek (
el-GR
) - Indonesian (
id-ID
) - Italian (
it-IT
) - Japanese (
ja-JP
) - Georgian (
ka-GE
) - Korean (
ko-KR
) - Norwegian (Bokmål) (
nb-NO
) - Persian (Farsi) (
fa
) - Polish (
pl-PL
) - Portuguese (Brazilian) (
pt-BR
) - Romanian (
ro-RO
) - Russian (
ru-RU
) - Serbian (
sr-SP
) - Spanish (
es-ES
) - Swedish (
sv-SE
) - Turkish (
tr-TR
) - Ukrainian (
uk-UA
) - Vietnamese (
vi-VN
)
If you don't see a language you need on the list, tell us and we'll quickly add it.