feat: translation (#389)
This commit is contained in:
parent
e2e115ebeb
commit
df9066eae0
43 changed files with 1466 additions and 47 deletions
|
|
@ -7,7 +7,8 @@ import {
|
|||
TFeedInfo,
|
||||
TNoteListMode,
|
||||
TRelaySet,
|
||||
TThemeSetting
|
||||
TThemeSetting,
|
||||
TTranslationServiceConfig
|
||||
} from '@/types'
|
||||
|
||||
class LocalStorageService {
|
||||
|
|
@ -27,6 +28,7 @@ class LocalStorageService {
|
|||
private autoplay: boolean = true
|
||||
private hideUntrustedInteractions: boolean = false
|
||||
private hideUntrustedNotifications: boolean = false
|
||||
private translationServiceConfigMap: Record<string, TTranslationServiceConfig> = {}
|
||||
|
||||
constructor() {
|
||||
if (!LocalStorageService.instance) {
|
||||
|
|
@ -109,6 +111,13 @@ class LocalStorageService {
|
|||
? storedHideUntrustedNotifications === 'true'
|
||||
: hideUntrustedEvents
|
||||
|
||||
const translationServiceConfigMapStr = window.localStorage.getItem(
|
||||
StorageKey.TRANSLATION_SERVICE_CONFIG_MAP
|
||||
)
|
||||
if (translationServiceConfigMapStr) {
|
||||
this.translationServiceConfigMap = JSON.parse(translationServiceConfigMapStr)
|
||||
}
|
||||
|
||||
// Clean up deprecated data
|
||||
window.localStorage.removeItem(StorageKey.ACCOUNT_PROFILE_EVENT_MAP)
|
||||
window.localStorage.removeItem(StorageKey.ACCOUNT_FOLLOW_LIST_EVENT_MAP)
|
||||
|
|
@ -290,6 +299,18 @@ class LocalStorageService {
|
|||
hideUntrustedNotifications.toString()
|
||||
)
|
||||
}
|
||||
|
||||
getTranslationServiceConfig(pubkey?: string | null) {
|
||||
return this.translationServiceConfigMap[pubkey ?? '_'] ?? { service: 'jumble' }
|
||||
}
|
||||
|
||||
setTranslationServiceConfig(config: TTranslationServiceConfig, pubkey?: string | null) {
|
||||
this.translationServiceConfigMap[pubkey ?? '_'] = config
|
||||
window.localStorage.setItem(
|
||||
StorageKey.TRANSLATION_SERVICE_CONFIG_MAP,
|
||||
JSON.stringify(this.translationServiceConfigMap)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const instance = new LocalStorageService()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue