starting to add spanish language translation
This commit is contained in:
@@ -12,10 +12,14 @@ import * as Device from 'expo-device';
|
||||
import {useEffect, useRef, useState} from 'react';
|
||||
import {handleLogin} from '../../../functions/biometricAuthentication';
|
||||
import {getLocalStorageItem, setLocalStorageItem} from '../../../functions';
|
||||
import {Trans, useTranslation} from 'react-i18next';
|
||||
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
||||
|
||||
export default function HomeLogin(props) {
|
||||
const {height} = useWindowDimensions();
|
||||
const fadeAnim = useRef(new Animated.Value(height / 2 - 75)).current;
|
||||
const {t} = useTranslation();
|
||||
const insets = useSafeAreaInsets();
|
||||
|
||||
async function moveLogo(type) {
|
||||
Animated.timing(fadeAnim, {
|
||||
@@ -75,14 +79,14 @@ export default function HomeLogin(props) {
|
||||
BTN,
|
||||
{backgroundColor: COLORS.primary, marginTop: 0, marginBottom: 15},
|
||||
]}>
|
||||
<Text style={styles.btnText}>Use Pin</Text>
|
||||
<Text style={styles.btnText}>{t('adminLogin.home.button')}</Text>
|
||||
</TouchableOpacity>
|
||||
<Text
|
||||
style={[
|
||||
styles.appName,
|
||||
{
|
||||
color: props.theme ? COLORS.darkModeText : COLORS.lightModeText,
|
||||
marginBottom: Device.osName === 'Android' ? 15 : 0,
|
||||
marginBottom: Device.osName === 'Android' ? insets.bottom + 10 : 0,
|
||||
},
|
||||
]}>
|
||||
Blitz Wallet
|
||||
|
||||
@@ -15,11 +15,28 @@ import {
|
||||
terminateAccount,
|
||||
} from '../../../functions';
|
||||
import {COLORS, FONT, SIZES} from '../../../constants';
|
||||
import {useTranslation} from 'react-i18next';
|
||||
import {useGlobalContextProvider} from '../../../../context-store/context';
|
||||
|
||||
export default function PinPage(props) {
|
||||
const [pin, setPin] = useState([null, null, null, null]);
|
||||
const [error, setError] = useState(false);
|
||||
const [pinEnterCount, setPinEnterCount] = useState(0);
|
||||
const {selectedLanguage} = useGlobalContextProvider();
|
||||
const {t} = useTranslation();
|
||||
|
||||
function formatSpanish(data) {
|
||||
let array = data.split(8);
|
||||
const newValue = 8 - pinEnterCount;
|
||||
|
||||
for (let i = array.length - 1; i >= 1; i--) {
|
||||
array[i + 1] = array[i];
|
||||
}
|
||||
|
||||
array[1] = newValue;
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const filteredPin = pin.filter(pin => {
|
||||
@@ -70,7 +87,9 @@ export default function PinPage(props) {
|
||||
color: props.theme ? COLORS.darkModeText : COLORS.lightModeText,
|
||||
},
|
||||
]}>
|
||||
{error ? 'Wrong PIN, try again' : 'Enter 4-digit PIN'}
|
||||
{error
|
||||
? t('adminLogin.pinPage.wrongPinError')
|
||||
: t('adminLogin.pinPage.enterPinMessage')}
|
||||
</Text>
|
||||
<Text
|
||||
style={[
|
||||
@@ -79,7 +98,9 @@ export default function PinPage(props) {
|
||||
color: props.theme ? COLORS.darkModeText : COLORS.lightModeText,
|
||||
},
|
||||
]}>
|
||||
{8 - pinEnterCount} attempts left
|
||||
{selectedLanguage === 'sp'
|
||||
? formatSpanish(t('adminLogin.pinPage.attemptsText'))
|
||||
: 8 - pinEnterCount + ' ' + t('adminLogin.pinPage.attemptsText')}
|
||||
</Text>
|
||||
<View style={styles.dotContainer}>
|
||||
<View
|
||||
@@ -332,6 +353,8 @@ const styles = StyleSheet.create({
|
||||
marginLeft: 'auto',
|
||||
},
|
||||
header: {
|
||||
width: '95',
|
||||
textAlign: 'center',
|
||||
fontSize: SIZES.large,
|
||||
fontWeight: 'bold',
|
||||
marginTop: 50,
|
||||
|
||||
@@ -19,11 +19,13 @@ import {
|
||||
setLocalStorageItem,
|
||||
} from '../../functions';
|
||||
import {getTransactions} from '../../functions/SDK';
|
||||
import {useTranslation} from 'react-i18next';
|
||||
|
||||
export default function ConnectingToNodeLoadingScreen({navigation: navigate}) {
|
||||
const onBreezEvent = globalOnBreezEvent(navigate);
|
||||
const {theme, toggleNodeInformation} = useGlobalContextProvider();
|
||||
const [errorText, setErrorText] = useState('');
|
||||
const [hasError, setHasError] = useState(null);
|
||||
const {t} = useTranslation();
|
||||
|
||||
useEffect(() => {
|
||||
initWallet();
|
||||
@@ -48,7 +50,9 @@ export default function ConnectingToNodeLoadingScreen({navigation: navigate}) {
|
||||
styles.waitingText,
|
||||
{color: theme ? COLORS.darkModeText : COLORS.lightModeText},
|
||||
]}>
|
||||
{errorText ? errorText : `We're setting things up. Hang tight!`}
|
||||
{hasError
|
||||
? t(`loadingScreen.errorText${hasError}`)
|
||||
: t('loadingScreen.loadingText')}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
@@ -140,7 +144,7 @@ export default function ConnectingToNodeLoadingScreen({navigation: navigate}) {
|
||||
toggleNodeInformation({
|
||||
didConnectToNode: false,
|
||||
});
|
||||
setErrorText('Error connecting to your node. Try reloading the app.');
|
||||
setHasError(1);
|
||||
console.log(err, 'homepage connection to node err');
|
||||
}
|
||||
}
|
||||
@@ -153,7 +157,7 @@ export default function ConnectingToNodeLoadingScreen({navigation: navigate}) {
|
||||
toggleNodeInformation({
|
||||
didConnectToNode: false,
|
||||
});
|
||||
setErrorText('Error connecting to your node. Try reloading the app.');
|
||||
hasError(1);
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import {createContext, useState, useContext, useEffect} from 'react';
|
||||
import {getLocalStorageItem, setLocalStorageItem} from '../app/functions';
|
||||
import {useColorScheme} from 'react-native';
|
||||
import {setStatusBarStyle} from 'expo-status-bar';
|
||||
import {removeLocalStorageItem} from '../app/functions/localStorage';
|
||||
import {useTranslation} from 'react-i18next';
|
||||
|
||||
// Initiate context
|
||||
const GlobalContextManger = createContext();
|
||||
@@ -25,6 +25,8 @@ const GlobalContextProvider = ({children}) => {
|
||||
const [userBalanceDenomination, setUserBalanceDenomination] = useState('');
|
||||
const [selectedLanguage, setSelectedLanguage] = useState('');
|
||||
|
||||
const {i18n} = useTranslation();
|
||||
|
||||
function toggleTheme(peram) {
|
||||
const mode = peram ? 'light' : 'dark';
|
||||
setStatusBarStyle(mode);
|
||||
@@ -51,7 +53,8 @@ const GlobalContextProvider = ({children}) => {
|
||||
}
|
||||
function toggleSelectedLanguage(language) {
|
||||
setLocalStorageItem('userSelectedLanguage', JSON.stringify(language));
|
||||
setUserBalanceDenomination(language);
|
||||
i18n.changeLanguage(language);
|
||||
setSelectedLanguage(language);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
@@ -85,8 +88,8 @@ const GlobalContextProvider = ({children}) => {
|
||||
setUserBalanceDenomination(userBalanceDenomination);
|
||||
else setUserBalanceDenomination('sats');
|
||||
|
||||
if (selectedLanguage) setSelectedLanguage(selectedLanguage);
|
||||
else setSelectedLanguage('en');
|
||||
if (selectedLanguage) toggleSelectedLanguage('sp');
|
||||
else toggleSelectedLanguage('en');
|
||||
})();
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'intl-pluralrules';
|
||||
import i18n from 'i18next';
|
||||
import {initReactI18next} from 'react-i18next';
|
||||
|
||||
import enTranslation from './locales/en/translation.json';
|
||||
import spTranslation from './locales/sp/translation.json';
|
||||
|
||||
i18n.use(initReactI18next).init({
|
||||
debug: true,
|
||||
fallbackLng: 'en',
|
||||
supportedLngs: ['en', 'sp'],
|
||||
resources: {
|
||||
en: {
|
||||
translation: enTranslation,
|
||||
},
|
||||
sp: {
|
||||
translation: spTranslation,
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -5,5 +5,6 @@
|
||||
import {AppRegistry} from 'react-native';
|
||||
import App from './App';
|
||||
import app from './app.config';
|
||||
import './i18n'; // for translation option
|
||||
|
||||
AppRegistry.registerComponent(app.name, () => App);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"adminLogin": {
|
||||
"home": {
|
||||
"button": "Use Pin"
|
||||
},
|
||||
"pinPage": {
|
||||
"wrongPinError": "Wrong PIN, try again",
|
||||
"enterPinMessage": "Enter 4-digit PIN",
|
||||
"attemptsText": "attempts left"
|
||||
}
|
||||
},
|
||||
"loadingScreen": {
|
||||
"loadingText": "We're setting things up. Hang tight!",
|
||||
"errorText1": "Error connecting to your node. Try reloading the app."
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"adminLogin": {
|
||||
"home": {
|
||||
"button": "Usar Pin"
|
||||
},
|
||||
"pinPage": {
|
||||
"wrongPinError": "PIN incorrecto, inténtelo de nuevo",
|
||||
"enterPinMessage": "Ingresa el PIN de 4 dígitos",
|
||||
"attemptsText": "Quedan 8 intentos"
|
||||
}
|
||||
},
|
||||
"loadingScreen": {
|
||||
"loadingText": "Estamos preparando las cosas. ¡Agárrate fuerte!",
|
||||
"errorText1": "Error al conectarse al nodo. Intente volver a cargar la aplicación."
|
||||
}
|
||||
}
|
||||
Generated
+82
-3
@@ -24,6 +24,7 @@
|
||||
"ecpair": "2.1.0",
|
||||
"expo": "^49.0.23",
|
||||
"expo-barcode-scanner": "~12.5.3",
|
||||
"expo-camera": "~13.4.4",
|
||||
"expo-clipboard": "~4.3.1",
|
||||
"expo-constants": "~14.4.2",
|
||||
"expo-crypto": "~12.4.1",
|
||||
@@ -36,8 +37,11 @@
|
||||
"expo-status-bar": "~1.6.0",
|
||||
"expo-task-manager": "~11.3.0",
|
||||
"expo-web-browser": "~12.3.2",
|
||||
"i18next": "^23.10.1",
|
||||
"intl-pluralrules": "^2.0.1",
|
||||
"liquidjs-lib": "6.0.2-liquid.34",
|
||||
"react": "18.2.0",
|
||||
"react-i18next": "^14.1.0",
|
||||
"react-native": "0.72.10",
|
||||
"react-native-gesture-handler": "~2.12.0",
|
||||
"react-native-qrcode-svg": "6.2.0",
|
||||
@@ -2046,9 +2050,9 @@
|
||||
"integrity": "sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA=="
|
||||
},
|
||||
"node_modules/@babel/runtime": {
|
||||
"version": "7.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.2.tgz",
|
||||
"integrity": "sha512-mM8eg4yl5D6i3lu2QKPuPH4FArvJ8KhTofbE7jwMUv9KX5mBvwPAqnV3MlyBNqdp9RyRKP6Yck8TrfYrPvX3bg==",
|
||||
"version": "7.24.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.0.tgz",
|
||||
"integrity": "sha512-Chk32uHMg6TnQdvw2e9IlqPpFX/6NLuK0Ys2PqLb7/gL5uFn9mXvK715FGLlOLQrcO4qIkNHkvPGktzzXexsFw==",
|
||||
"dependencies": {
|
||||
"regenerator-runtime": "^0.14.0"
|
||||
},
|
||||
@@ -10814,6 +10818,17 @@
|
||||
"expo": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-camera": {
|
||||
"version": "13.4.4",
|
||||
"resolved": "https://registry.npmjs.org/expo-camera/-/expo-camera-13.4.4.tgz",
|
||||
"integrity": "sha512-7k54APbpSulUDR2CrD5SrmKjCdfdg4tqKRpbBOKc2J2MIBHhunExU77435JDYSejHRY5bfRHZsEp3yKwR862uw==",
|
||||
"dependencies": {
|
||||
"invariant": "^2.2.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"expo": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-clipboard": {
|
||||
"version": "4.3.1",
|
||||
"resolved": "https://registry.npmjs.org/expo-clipboard/-/expo-clipboard-4.3.1.tgz",
|
||||
@@ -12104,6 +12119,14 @@
|
||||
"integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/html-parse-stringify": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz",
|
||||
"integrity": "sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg==",
|
||||
"dependencies": {
|
||||
"void-elements": "3.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/http-errors": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
|
||||
@@ -12147,6 +12170,28 @@
|
||||
"node": ">=10.17.0"
|
||||
}
|
||||
},
|
||||
"node_modules/i18next": {
|
||||
"version": "23.10.1",
|
||||
"resolved": "https://registry.npmjs.org/i18next/-/i18next-23.10.1.tgz",
|
||||
"integrity": "sha512-NDiIzFbcs3O9PXpfhkjyf7WdqFn5Vq6mhzhtkXzj51aOcNuPNcTwuYNuXCpHsanZGHlHKL35G7huoFeVic1hng==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://locize.com"
|
||||
},
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://locize.com/i18next.html"
|
||||
},
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
@@ -12309,6 +12354,11 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/intl-pluralrules": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/intl-pluralrules/-/intl-pluralrules-2.0.1.tgz",
|
||||
"integrity": "sha512-astxTLzIdXPeN0K9Rumi6LfMpm3rvNO0iJE+h/k8Kr/is+wPbRe4ikyDjlLr6VTh/mEfNv8RjN+gu3KwDiuhqg=="
|
||||
},
|
||||
"node_modules/invariant": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz",
|
||||
@@ -18211,6 +18261,27 @@
|
||||
"react": ">=17.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-i18next": {
|
||||
"version": "14.1.0",
|
||||
"resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-14.1.0.tgz",
|
||||
"integrity": "sha512-3KwX6LHpbvGQ+sBEntjV4sYW3Zovjjl3fpoHbUwSgFHf0uRBcbeCBLR5al6ikncI5+W0EFb71QXZmfop+J6NrQ==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.23.9",
|
||||
"html-parse-stringify": "^3.0.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"i18next": ">= 23.2.3",
|
||||
"react": ">= 16.8.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
},
|
||||
"react-native": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-is": {
|
||||
"version": "16.13.1",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
|
||||
@@ -20477,6 +20548,14 @@
|
||||
"resolved": "https://registry.npmjs.org/vlq/-/vlq-1.0.1.tgz",
|
||||
"integrity": "sha512-gQpnTgkubC6hQgdIcRdYGDSDc+SaujOdyesZQMv6JlfQee/9Mp0Qhnys6WxDWvQnL5WZdT7o2Ul187aSt0Rq+w=="
|
||||
},
|
||||
"node_modules/void-elements": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz",
|
||||
"integrity": "sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/walker": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz",
|
||||
|
||||
@@ -39,8 +39,11 @@
|
||||
"expo-status-bar": "~1.6.0",
|
||||
"expo-task-manager": "~11.3.0",
|
||||
"expo-web-browser": "~12.3.2",
|
||||
"i18next": "^23.10.1",
|
||||
"intl-pluralrules": "^2.0.1",
|
||||
"liquidjs-lib": "6.0.2-liquid.34",
|
||||
"react": "18.2.0",
|
||||
"react-i18next": "^14.1.0",
|
||||
"react-native": "0.72.10",
|
||||
"react-native-gesture-handler": "~2.12.0",
|
||||
"react-native-qrcode-svg": "6.2.0",
|
||||
|
||||
Reference in New Issue
Block a user