🚨 Handled issue where variable was used before initialisation

This commit is contained in:
Mawoka
2022-06-12 12:06:41 +02:00
parent 427bf9ebaf
commit a747a20c37
+9 -9
View File
@@ -4,6 +4,15 @@ import type { TType } from './translation-service';
import type { Readable, Writable } from 'svelte/store';
import { getContext, setContext } from 'svelte';
export const setLocalization = (context: I18nContext) => {
return setContext<I18nContext>(CONTEXT_KEY, context);
};
// To make retrieving the t function easier.
export const getLocalization = () => {
return getContext<I18nContext>(CONTEXT_KEY);
};
export const initLocalizationContext = () => {
// Initialize our services
const i18n = new I18nService();
@@ -25,12 +34,3 @@ export type I18nContext = {
t: Readable<TType>;
currentLanguage: Writable<string>;
};
export const setLocalization = (context: I18nContext) => {
return setContext<I18nContext>(CONTEXT_KEY, context);
};
// To make retrieving the t function easier.
export const getLocalization = () => {
return getContext<I18nContext>(CONTEXT_KEY);
};