ripal-ui 1.0.2 → 1.0.4
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/config.js +2 -2
- package/elements/Separator.tsx +0 -1
- package/elements/Switch.tsx +0 -1
- package/elements/Text.tsx +19 -3
- package/package.json +1 -1
- package/scripts/generateConfig.js +14 -0
package/config.js
CHANGED
package/elements/Separator.tsx
CHANGED
package/elements/Switch.tsx
CHANGED
package/elements/Text.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, { FC } from "react";
|
|
1
|
+
import React, { FC, useEffect, useState } from "react";
|
|
2
2
|
import { Text as RNText, TextStyle } from "react-native";
|
|
3
3
|
import { useFonts, Poppins_300Light, Poppins_400Regular, Poppins_500Medium, Poppins_600SemiBold, Poppins_700Bold, Poppins_900Black } from "@expo-google-fonts/poppins";
|
|
4
4
|
import config from "../config";
|
|
5
|
+
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
5
6
|
|
|
6
7
|
interface TextProps {
|
|
7
8
|
children: React.ReactNode;
|
|
@@ -35,13 +36,28 @@ const Text: FC<TextProps> = ({
|
|
|
35
36
|
Poppins_700Bold,
|
|
36
37
|
Poppins_900Black
|
|
37
38
|
});
|
|
39
|
+
const [lang, setLang] = useState(config.appLangs.default);
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
console.log('hehe');
|
|
43
|
+
|
|
44
|
+
AsyncStorage.getItem('app_lang').then(appLang => {
|
|
45
|
+
if (appLang != null) {
|
|
46
|
+
console.log('setting to ', appLang);
|
|
47
|
+
setLang(appLang);
|
|
48
|
+
}
|
|
49
|
+
console.log(appLang);
|
|
50
|
+
});
|
|
51
|
+
}, []);
|
|
52
|
+
|
|
53
|
+
if (lang !== null) {
|
|
40
54
|
const ogChildren = children;
|
|
41
55
|
if (typeof children === "string") {
|
|
56
|
+
console.log(lang);
|
|
57
|
+
|
|
42
58
|
children = children.split('.').reduce((acc, key) => {
|
|
43
59
|
return acc && acc[key] !== undefined ? acc[key] : ogChildren;
|
|
44
|
-
}, config.appLangs[
|
|
60
|
+
}, config.appLangs[lang]);
|
|
45
61
|
}
|
|
46
62
|
}
|
|
47
63
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
// ./scripts/generateConfig.js
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
|
+
const { exec } = require('child_process');
|
|
5
|
+
|
|
6
|
+
// Installing AsyncStorage
|
|
7
|
+
exec('npm install @react-native-async-storage/async-storage', (error, stdout, stderr) => {
|
|
8
|
+
if (error) {
|
|
9
|
+
console.error(`Error installing dependencies: ${error.message}`);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (stderr) {
|
|
13
|
+
console.error(`stderr: ${stderr}`);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
generateConfig(); // Call function to generate config after installing
|
|
17
|
+
});
|
|
4
18
|
|
|
5
19
|
// Define the config file content
|
|
6
20
|
const configContent = `const config = {
|