Skip to main content
Version: v4

Localize

Overview

CometChat UI Kit provides language localization to adapt to the language of a specific country or region. The CometChatLocalize class allows you to detect the language of your users based on their browser or device settings, and set the language accordingly.

CometChatLocalize is a class that includes methods related to locale. Developers can use these methods to change the language of the UI Kit library.

Presently, the UI Kit supports 12 languages for localization, which are:

  • English (en, en-US, en-GB)
  • Chinese (zh, zh-TW)
  • Spanish (es)
  • Hindi (hi)
  • Russian (ru)
  • Portuguese (pt)
  • Malay (ms)
  • French (fr)
  • German (de)
  • Swedish (sv)
  • Lithuanian (lt)
  • Hungarian (hu)

Methods

Here are the methods included in the CometChatLocalize class:

  • set(locale: Language): This method is used to set the language in the UI Kit. It takes the enum value from Language enum and sets the value accordingly.

  • getLocale( ): This method is used to get the current language. By default, it will return the current language from the device/browser.

Usage

Here is how you can put these methods into use:

// Set Language
CometChatLocalize().set(locale: .french)

// Get Language
CometChatLocalize().getLocale()

By using the CometChatLocalize class, you can provide a user-friendly, localized experience to your users, enhancing the overall user experience within your application.