import { type SupportedLanguageKeys } from '../components/TranslationTools/TranslationTools.models' import { newTranslationInstance } from '../services/TranslationHelpers' import { RESOURCES } from './Resources' const LibraryTranslationInstance = newTranslationInstance(RESOURCES) LibraryTranslationInstance.init() LibraryTranslationInstance.changeLanguage( (typeof window !== 'undefined' && typeof localStorage !== 'undefined' && localStorage.getItem('language_setting')) || 'en', ) /** * Syncs the library translation language with localStorage and updates the i18next instance * @param language - The language code to sync (e.g., 'en', 'zh') */ export const syncLibraryLanguage = (language: SupportedLanguageKeys): void => { if (typeof window !== 'undefined' && typeof localStorage !== 'undefined') { localStorage.setItem('language_setting', language) } LibraryTranslationInstance.changeLanguage(language) } export default LibraryTranslationInstance