mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-23 05:53:09 +03:00
Load i18n on Start (#1069)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
b103ac743c
commit
101c8eb4c3
@ -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) {
|
||||
|
@ -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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user