Load i18n on Start (#1069)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2022-02-28 10:42:34 +07:00 committed by GitHub
parent b103ac743c
commit 101c8eb4c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -43,6 +43,20 @@ export function addStringsLoader (plugin: Plugin, loader: Loader): void {
loaders.set(plugin, loader)
}
/**
* Perform load of all internationalization sources for all plugins available.
* @public
*/
export async function loadPluginStrings (locale: string): Promise<void> {
for (const [plugin] of loaders) {
let messages = translations.get(plugin)
if (messages === undefined) {
messages = await loadTranslationsForComponent(plugin, locale)
translations.set(plugin, messages)
}
}
}
async function loadTranslationsForComponent (plugin: Plugin, locale: string): Promise<Messages | Status> {
const loader = loaders.get(plugin)
if (loader === undefined) {

View File

@ -15,7 +15,7 @@
<script lang="ts">
import { setContext, onMount } from 'svelte'
import platform, { setMetadata } from '@anticrm/platform'
import platform, { loadPluginStrings, setMetadata } from '@anticrm/platform'
const getCurrentTheme = (): string => localStorage.getItem('theme') ?? 'theme-dark'
const getCurrnetFontSize = (): string => localStorage.getItem('fontsize') ?? 'normal-font'
@ -58,6 +58,7 @@
setRootColors(currentTheme)
setRootFontSize(currentFontSize)
setMetadata(platform.metadata.locale, currentLanguage)
loadPluginStrings(currentLanguage)
})
</script>