@aarhus-university/au-lib-react-components 10.19.2 → 10.20.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.
- package/package.json +1 -1
- package/src/lib/hooks.ts +6 -2
- package/stories/lib/helpers.tsx +2 -1
package/package.json
CHANGED
package/src/lib/hooks.ts
CHANGED
|
@@ -33,7 +33,11 @@ const useModal = (
|
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
const useTranslation = <T>(
|
|
36
|
+
const useTranslation = <T>(
|
|
37
|
+
initialObject: T,
|
|
38
|
+
promises: [Promise<any>, Promise<any> | null],
|
|
39
|
+
lang: string,
|
|
40
|
+
): T => {
|
|
37
41
|
const [translations, setTranslations] = useState<T>(initialObject);
|
|
38
42
|
const loadTranslation = async (): Promise<void> => {
|
|
39
43
|
const translation = await Promise.all(promises);
|
|
@@ -46,7 +50,7 @@ const useTranslation = <T>(initialObject: T, promises: [Promise<any>, Promise<an
|
|
|
46
50
|
|
|
47
51
|
useEffect(() => {
|
|
48
52
|
loadTranslation();
|
|
49
|
-
}, []);
|
|
53
|
+
}, [lang]);
|
|
50
54
|
|
|
51
55
|
return translations;
|
|
52
56
|
};
|
package/stories/lib/helpers.tsx
CHANGED
|
@@ -55,8 +55,9 @@ const ThemeLanguageWrapper = ({
|
|
|
55
55
|
defaultLabels,
|
|
56
56
|
importPromises,
|
|
57
57
|
translationContext,
|
|
58
|
+
lang,
|
|
58
59
|
}) => {
|
|
59
|
-
const translations = useTranslation<typeof defaultLabels>(defaultLabels, importPromises);
|
|
60
|
+
const translations = useTranslation<typeof defaultLabels>(defaultLabels, importPromises, lang);
|
|
60
61
|
useEffect(() => {
|
|
61
62
|
const body = document.querySelector('body');
|
|
62
63
|
if (body) {
|