Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-react-uikit-v7.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

FieldValue
Locale proplocale="fr" on CometChatProvider
Defaulten-us
Languages19 built-in: de, en-gb, en-us, es, fr, hi, hu, it, ja, ko, lt, ms, nl, pt, ru, sv, tr, zh, zh-tw
HookuseLocale(){ getLocalizedString, language }
Static accessCometChatLocalize.getSharedInstance()?.t(key)
Custom translationsPass via CometChatLocalize constructor or addTranslation()

Overview

The UI Kit ships with translations for 19 languages. All user-facing text (button labels, status messages, timestamps, error messages) is resolved through translation keys. Set the locale prop on CometChatProvider to switch languages.

Setting the Language

<CometChatProvider
  appId="YOUR_APP_ID"
  region="us"
  authKey="YOUR_AUTH_KEY"
  uid="cometchat-uid-1"
  locale="fr"
>
  <MyChatApp />
</CometChatProvider>

Supported Languages

CodeLanguage
en-usEnglish (US) — default
en-gbEnglish (UK)
deGerman
esSpanish
frFrench
hiHindi
huHungarian
itItalian
jaJapanese
koKorean
ltLithuanian
msMalay
nlDutch
ptPortuguese
ruRussian
svSwedish
trTurkish
zhChinese (Simplified)
zh-twChinese (Traditional)

Accessing Translations in Components

Use the useLocale hook:
import { useLocale } from "@cometchat/chat-uikit-react";

function MyComponent() {
  const { getLocalizedString, language } = useLocale();

  return <p>{getLocalizedString("message_deleted")}</p>;
  // Renders: "This message was deleted" (en-us)
  // Renders: "Ce message a été supprimé" (fr)
}

Adding Custom Translations

Override or add translation keys for a language:
import { CometChatLocalize } from "@cometchat/chat-uikit-react";

const localize = CometChatLocalize.getSharedInstance();
localize?.addTranslation("en-us", {
  "custom_greeting": "Welcome to our chat!",
  "message_deleted": "Message removed",  // Override built-in key
});

Fallback Language

If a key is not found in the current language, the system falls back to the fallback language (default: en-us). Configure via CometChatLocalize:
const localize = new CometChatLocalize({
  language: "fr",
  fallbackLanguage: "en-us",
});

Date & Time Localization

Date formatting respects the locale. The CometChatDate component and all timestamp displays use locale-aware formatting:
  • Relative time: “2 minutes ago”, “il y a 2 minutes”
  • Day names: “Monday”, “Lundi”
  • Date formats: “12/25/2024” (en-us), “25/12/2024” (en-gb)

Static Access (Non-React Code)

For plugins and utilities that run outside React components:
import { CometChatLocalize } from "@cometchat/chat-uikit-react";

const t = CometChatLocalize.getSharedInstance()?.t;
const text = t?.("message_deleted") ?? "This message was deleted";

Differences from v6

v6v7
CometChatLocalize.setLanguage("fr")locale="fr" prop on CometChatProvider
Global static stateReact context via LocaleProvider
Manual init requiredAutomatic — provider handles it
Same 19 languagesSame 19 languages