CometChat UIKit supports 19 languages out of the box with runtime language switching. You can override translations globally without modifying source files.
import { CometChatLocalize } from '@cometchat/chat-uikit-angular';// Initialize with a specific languageCometChatLocalize.init({ language: 'es', timezone: 'Europe/Madrid'});// Switch language at runtimeCometChatLocalize.setCurrentLanguage('fr');
CometChatLocalize.init({ language: 'es', // Active language fallbackLanguage: 'en-US', // Fallback when key not found timezone: 'Europe/Madrid', // Timezone for date formatting disableAutoDetection: false, // Disable browser language detection disableDateTimeLocalization: false, // Disable date/time localization translationsForLanguage: { // Custom translations to merge 'en-US': { 'custom_key': 'value' } }, calendarObject: { // Custom date format (see Date/Time docs) today: 'HH:mm', yesterday: '[Yesterday]', lastWeek: 'dddd', otherDays: 'DD/MM/YYYY' }, missingKeyHandler: (key) => { // Called when a key is not found console.warn(`Missing translation: ${key}`); }});
Use CalendarObject to customize how dates and times are displayed throughout the UIKit. Supports relative time formatting for minutes and hours.
Changing this format globally updates the date and time representation wherever it is used. If a component-specific CalendarObject is provided, it takes higher precedence over the global settings.
Property
Type
Description
today
string
Format for dates on the same day. Example: "Today at hh:mm A"
yesterday
string
Format for dates on the previous day. Example: "Yesterday at hh:mm A"
lastWeek
string
Format for dates within the last 7 days. Example: "Last week on dddd"
otherDays
string
Format for dates that do not fit other categories. Example: "DD MMM YYYY, hh:mm A"