-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontext.tsx
41 lines (38 loc) · 948 Bytes
/
context.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from "react";
export type Translations = Record<string, Record<string, string>>;
export interface ContextProps {
/**
* @name keys
* Keys for the storage of various values in LocalStorage as languages
*/
key?: string;
defaultLanguage: string;
translations: Translations;
}
/**
* @name TranslationContext
* Context for the translation of the application
*
* @param key
* Key for the storage of various values in LocalStorage as languages
*
* @param defaultLanguage
* Default language of the application
*
* @param translations
* Translations of the application
*
* @returns
* Context for the translation of the application
*
* @example ```tsx
* <TranslationContext.Provider value={{ key: "language", defaultLanguage: "en", translations }}>
* <App />
* </TranslationContext.Provider>
* ```
*
*
*/
export const TranslationContext = React.createContext<ContextProps | undefined>(
undefined
);