mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-20 15:20:18 +00: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)
|
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> {
|
async function loadTranslationsForComponent (plugin: Plugin, locale: string): Promise<Messages | Status> {
|
||||||
const loader = loaders.get(plugin)
|
const loader = loaders.get(plugin)
|
||||||
if (loader === undefined) {
|
if (loader === undefined) {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { setContext, onMount } from 'svelte'
|
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 getCurrentTheme = (): string => localStorage.getItem('theme') ?? 'theme-dark'
|
||||||
const getCurrnetFontSize = (): string => localStorage.getItem('fontsize') ?? 'normal-font'
|
const getCurrnetFontSize = (): string => localStorage.getItem('fontsize') ?? 'normal-font'
|
||||||
@ -58,6 +58,7 @@
|
|||||||
setRootColors(currentTheme)
|
setRootColors(currentTheme)
|
||||||
setRootFontSize(currentFontSize)
|
setRootFontSize(currentFontSize)
|
||||||
setMetadata(platform.metadata.locale, currentLanguage)
|
setMetadata(platform.metadata.locale, currentLanguage)
|
||||||
|
loadPluginStrings(currentLanguage)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user