UNPKG

@cometchat/chat-uikit-react-native

Version:

Ready-to-use Chat UI Components for React Native

80 lines (79 loc) 2.43 kB
/** * Type for Translation objects, each language contains key-value pairs */ type Translation = { [key: string]: string; }; /** * Type for translations mapping language code to Translation */ type Translations = { [languageCode: string]: Translation; }; declare class CometChatLocalize { /**Properties and constants */ static fallbackLanguage: string; static locale: string; static rtlLanguages: string[]; static direction: Readonly<{ ltr: "ltr"; rtl: "rtl"; }>; /** The translations object now has a more explicit type */ static translations: Translations; /** * Needs to be called at the start of the application in order to set the language * @param {Object} - language & resources */ static init: ({ language, resources, }: { language?: string | undefined; resources?: Translations | undefined; }) => void; /** * Returns the native language * @returns {String} native language i.e. en-US */ static getNativeLanguage: () => string; /** * Returns the language code * @returns {String} language code i.e. en */ static getLanguageCode: () => string; /** * Returns the active language. Return fallback language if translation is not available for the active language * @returns {String} active language */ static getLocale: () => string; /** * Set the active language * @param {String} language */ static setLocale: (language: string) => void; /** * Accepts the string to localize and return the localized string * @param {String} str * @returns {String} localized str */ static localize: (str: string) => string; /** * Sets the default language if no language is passed in init method */ static setDefaultLanguage: () => void; /** * Returns true if the active language is rtl otherwise return false * @returns {Boolean} whether the language is rtl or not */ static isRTL: () => boolean; /** * Returns rtl or ltr based on the active language * @returns {String} the direction of the active language */ static getDir: () => string; } /** * Returns localized string based on active language * @param {String} str * @returns {String} localized str */ declare const localize: (str: string) => string; export { CometChatLocalize, localize };