@firedesktop/react-base 1.50.0 → 1.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ import React, { useEffect } from 'react';
2
+
3
+ import LanguageManager from './LanguageManager';
4
+
5
+ export type Labels_Type = {
6
+ language: string
7
+ }
8
+ export type languageLoaderParamsType = {
9
+ labels?: Labels_Type
10
+ language: string
11
+ onLanguageLoad: (language?: Labels_Type) => void
12
+ path: string
13
+ }
14
+
15
+ export default function LanguageReturner({ labels, language, onLanguageLoad, path }: languageLoaderParamsType) {
16
+ const { loadLabels } = LanguageManager();
17
+
18
+ const fullPath = `${path}/${language}.json`;
19
+
20
+ // Do it on change language
21
+ useEffect(() => {
22
+ async function justAsync() {
23
+ if (!labels || !labels.language || labels.language !== language) {
24
+ console.log(`Loading Language Labels for this Path: ${path} in this fullpath: ${fullPath}`);
25
+ await loadLabels(fullPath).then((response: any) => {
26
+ console.log(`Loaded Language Labels for this Path: ${path} in this fullpath: ${fullPath}`, response);
27
+ onLanguageLoad(response);
28
+ }).catch((err: any) => {
29
+ console.error(`Problem loading the Path: ${path} Language Labels in this fullpath: ${fullPath}`);
30
+ });
31
+ }
32
+ }
33
+ justAsync();
34
+ // eslint-disable-next-line react-hooks/exhaustive-deps
35
+ }, [language]);
36
+
37
+ return (
38
+ <React.Fragment>
39
+ </React.Fragment>
40
+ );
41
+ }
@@ -0,0 +1,9 @@
1
+ import LanguageLoader from './LanguageLoader';
2
+ import LanguageManager from './LanguageManager';
3
+ import LanguageReturner from './LanguageReturner';
4
+
5
+ export {
6
+ LanguageLoader,
7
+ LanguageManager,
8
+ LanguageReturner
9
+ };
@@ -1,3 +0,0 @@
1
- {
2
- "typescript.tsdk": "node_modules\\typescript\\lib"
3
- }