Skip to main content
FieldValue
Importcom.cometchat.uikit.core.resources.localise.CometChatLocalize
Set languageCometChatLocalize.setLocale(context, Language.FRENCH)
Get languageCometChatLocalize.getLocale(context)
Supported languages19: ar, de, en, es, fr, hi, hu, it, ja, ko, lt, ms, nl, pl, pt, ru, sv, tr, zh
Override labelsres/values/strings.xml — override UI Kit string resource keys
RelatedTheme Introduction · Sound Manager
Set the CometChat UI Kit language and override UI text so your app matches your users’ locale.

Core Concepts

  • CometChatLocalize — utility object in chatuikit-core to set and read the UI Kit locale. Shared by both Kotlin XML and Jetpack Compose modules.
  • Language — constants for supported language codes (Language.ENGLISH, Language.FRENCH, etc.)
  • strings.xml — Android string resources that control visible text in UI Kit components. Override keys in your app’s strings.xml.

Supported Languages

LanguageCodeLanguageCode
ArabicarKoreanko
ChinesezhLithuanianlt
DutchnlMalayms
EnglishenPolishpl
FrenchfrPortuguesept
GermandeRussianru
HindihiSpanishes
HungarianhuSwedishsv
ItalianitTurkishtr
Japaneseja

Set the UI Kit Locale

Call CometChatLocalize.setLocale() before rendering any UI Kit components.
import com.cometchat.uikit.core.resources.localise.CometChatLocalize
import com.cometchat.uikit.core.resources.localise.Language

// Set language to Hindi
CometChatLocalize.setLocale(this, Language.HINDI)

// Read current locale
val currentLocale = CometChatLocalize.getLocale(this)

Override UI Kit Labels

Override any UI Kit string by adding the same key to your app’s res/values/strings.xml. No source code changes needed — Android’s resource merging handles it.
res/values/strings.xml
<resources>
    <!-- Override the conversations list title -->
    <string name="cometchat_chats" translatable="true">Conversations</string>

    <!-- Override the "typing" indicator text -->
    <string name="cometchat_typing" translatable="true">writing...</string>
</resources>
This works identically for both Kotlin XML Views and Jetpack Compose — both modules read from the same Android string resources.

Customize Date & Time Labels

Override how timestamps like “Today”, “Yesterday”, and “X mins ago” are displayed.
Set a DateTimeFormatterCallback on individual components:
import com.cometchat.uikit.kotlin.shared.interfaces.DateTimeFormatterCallback
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale

val messageList = findViewById<CometChatMessageList>(R.id.message_list)

messageList.setDateTimeFormatter(object : DateTimeFormatterCallback {
    private val dateFormatter = SimpleDateFormat("dd MMM yyyy", Locale.getDefault())

    override fun time(timestamp: Long): String = SimpleDateFormat("hh:mm a", Locale.getDefault()).format(Date(timestamp))
    override fun today(timestamp: Long): String = "Today"
    override fun yesterday(timestamp: Long): String = "Yesterday"
    override fun lastWeek(timestamp: Long): String = "Last Week"
    override fun otherDays(timestamp: Long): String = dateFormatter.format(Date(timestamp))
    override fun minutes(diffInMinutesFromNow: Long, timestamp: Long): String = "$diffInMinutesFromNow mins ago"
    override fun hours(diffInHourFromNow: Long, timestamp: Long): String = "$diffInHourFromNow hrs ago"
})

Additional API

MethodDescription
CometChatLocalize.setLocale(context, language)Sets the UI Kit language
CometChatLocalize.getLocale(context)Returns the current locale country code
CometChatLocalize.getLanguage(context)Returns the current locale language code
CometChatLocalize.isRtl(context)Checks if the current locale is right-to-left
CometChatLocalize.resetToDefault()Resets locale to system default
CometChatLocalize.createLocalizedContext(context, language)Creates a context with a specific locale without affecting the app globally