import type DictionaryPlugin from "src/main" ; import { App , FuzzySuggestModal } from "obsidian" ; import { LANGUAGES } from "src/_constants" ; import t from "src/l10n/helpers" ; export default class LanguageChooser extends FuzzySuggestModal < string > { plugin : DictionaryPlugin ; constructor ( app , plugin ) { super ( app ) ; this . plugin = plugin ; this . setPlaceholder ( t ( "Choose a Language" ) ) ; } getItems ( ) { const items = [ ] ; for ( const lang in LANGUAGES ) { items . push ( lang ) ; } return items ; } getItemText ( item ) { if ( item == this . plugin . settings . defaultLanguage ) { return LANGUAGES [ item ] + ' 🗸' ; } else { return LANGUAGES [ item ] ; } } async onChooseItem ( item ) { this . plugin . settings . defaultLanguage = item as keyof typeof LANGUAGES ; this . plugin . settings . normalLang = item as keyof typeof LANGUAGES ; await this . plugin . saveSettings ( ) ; this . close ( ) ; } }