feat:移除了弹窗,服务器添加sls
This commit is contained in:
49
apps/app-frontend/src/plugins/i18n-debug.ts
Normal file
49
apps/app-frontend/src/plugins/i18n-debug.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import {
|
||||
annotateFullDocument,
|
||||
clearAllAnnotations,
|
||||
hideKeyTooltip,
|
||||
I18N_DEBUG_KEY,
|
||||
type I18nDebugContext,
|
||||
initI18nDebugRuntime,
|
||||
} from '@modrinth/ui'
|
||||
import type { App } from 'vue'
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
|
||||
import { useTheming } from '@/store/theme'
|
||||
|
||||
export default {
|
||||
install(app: App) {
|
||||
const theming = useTheming()
|
||||
|
||||
const enabled = ref(theming.featureFlags.i18n_debug ?? false)
|
||||
const keyReveal = ref(false)
|
||||
const registry = reactive(new Map()) as Map<
|
||||
string,
|
||||
{ key: string; value: string; defaultMessage?: string; timestamp: number }
|
||||
>
|
||||
const panelOpen = ref(false)
|
||||
|
||||
const context: I18nDebugContext = { enabled, keyReveal, registry, panelOpen }
|
||||
app.provide(I18N_DEBUG_KEY, context)
|
||||
|
||||
initI18nDebugRuntime(context)
|
||||
|
||||
watch(
|
||||
() => theming.featureFlags.i18n_debug,
|
||||
(active) => {
|
||||
enabled.value = active
|
||||
if (!active) {
|
||||
keyReveal.value = false
|
||||
panelOpen.value = false
|
||||
document.body.classList.remove('i18n-debug')
|
||||
clearAllAnnotations()
|
||||
hideKeyTooltip()
|
||||
registry.clear()
|
||||
} else {
|
||||
document.body.classList.add('i18n-debug')
|
||||
annotateFullDocument(registry)
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
}
|
||||
23
apps/app-frontend/src/plugins/i18n.ts
Normal file
23
apps/app-frontend/src/plugins/i18n.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { I18N_INJECTION_KEY, type I18nContext } from '@modrinth/ui'
|
||||
import type { App } from 'vue'
|
||||
|
||||
import i18n from '@/i18n.config'
|
||||
|
||||
export default {
|
||||
install(app: App) {
|
||||
// Install vue-i18n as before
|
||||
app.use(i18n)
|
||||
|
||||
// Wrap it in our I18nContext interface
|
||||
const context: I18nContext = {
|
||||
locale: i18n.global.locale,
|
||||
t: (key, values) => i18n.global.t(key, values ?? {}) as string,
|
||||
setLocale: (newLocale) => {
|
||||
i18n.global.locale.value = newLocale
|
||||
},
|
||||
}
|
||||
|
||||
// Provide the context at app-level
|
||||
app.provide(I18N_INJECTION_KEY, context)
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user