Roo-Code/src/i18n/index.ts
Matt Rubens 38655825d4
Extension-side internationalization (#1757)
* Extension-side internationalization

* Update script

* Cleaner esbuild

* Turn off debugging

* PR feedback

* Update src/i18n/locales/en/common.json

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Update src/i18n/locales/ca/common.json

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-03-18 10:39:21 -04:00

41 lines
927 B
TypeScript

import i18next from "./setup"
/**
* Initialize i18next with the specified language
*
* @param language The language code to use
*/
export function initializeI18n(language: string): void {
i18next.changeLanguage(language)
}
/**
* Get the current language
*
* @returns The current language code
*/
export function getCurrentLanguage(): string {
return i18next.language
}
/**
* Change the current language
*
* @param language The language code to change to
*/
export function changeLanguage(language: string): void {
i18next.changeLanguage(language)
}
/**
* Translate a string using i18next
*
* @param key The translation key, can use namespace with colon, e.g. "common:welcome"
* @param options Options for interpolation or pluralization
* @returns The translated string
*/
export function t(key: string, options?: Record<string, any>): string {
return i18next.t(key, options)
}
export default i18next