🚨 Handled issue where variable was used before initialisation
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user