Skip to content

Commit

Permalink
LightningBox: add translation texts
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjoberg committed Nov 19, 2023
1 parent 31224d4 commit ef5ac7e
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 44 deletions.
31 changes: 30 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
"common": {
"generic": {
"lightningAddress": "Lightning Address",
"lightningBox": "Lightning Box",
"nodeAlias": "Node alias",
"description": "Description",
"amount": "Amount",
"fee": "Fee",
"search": "Search",
"viewInBlockExplorer": "View in block explorer",
"blocks": "{{numBlocks}} blocks"
"blocks": "{{numBlocks}} blocks",
"reason": "Reason: {{reason}}"
},
"buttons": {
"ok": "Ok",
Expand Down Expand Up @@ -1138,6 +1140,33 @@
"msg1": "To start using Lightning in Blixt Wallet",
"msg2": "send bitcoins to the address above"
},
"lightningBox.registration": {
"info": {
"welcome": "Welcome to the Lightning Box registration.",
"whatIs": "Lightning Box is a Lightning Address service provider that forwards payment requests directly to the phone, giving you a self-custodial Lightning Address for mobile devices.",
"persistentMode":"This service is dependent on persistent mode, because the app must stay active to receive incoming payments. Please make sure that battery optimization is turned off on your device. Otherwise this service may not work.",
"currentRules": "The service is free to use. However, due to technical reasons it currently requires a channel with the Lightning Box provider. It's currently not possible to change your Lightning Address after you have chosen one."
},
"prerequisites": {
"prerequisites": "Prerequisites",
"checkingEligibility": "Checking eligibility...",
"eligible": "Eligible",
"youHaveChannel": "You have a channel with the Lightning Box service.",
"notEligible": "Not eligible"
},
"registration": {
"registration": "Registration",
"fields": {
"address": "Address",
"messageToPayer": "Message to the payer"
},
"register": "Register"
}
},
"lightningBox.info": {
"yourLightningAddress": "Your Lightning Address by Lightning Box is:",
"showQrCode": "Show QR code"
},
"welcome.almostDone": {
"autopilot": {
"title": "Auto-open channels",
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/i18n.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const namespaces = {
experiment: "keysend.experiment",
},
lightningBox: {
manage: "lightningBox.manage",
registration: "lightningBox.registration",
info: "lightningBox.info",
},
lightningInfo: {
lightningInfo: "lightningInfo.lightningInfo",
Expand Down
12 changes: 7 additions & 5 deletions src/windows/LightningBox/LightningBoxInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface ILightningBoxProps {
navigation: StackNavigationProp<RootStackParamList, "LightningBox">;
}
export default function LightningBoxRegistration({ navigation }: ILightningBoxProps) {
const t = useTranslation(namespaces.lightningBox.manage).t;
const t = useTranslation(namespaces.lightningBox.info).t;

const lightningBoxAddress = useStoreState((store) => store.settings.lightningBoxAddress);
// const lightningBoxLnurlPayDesc = useStoreState(
Expand All @@ -36,7 +36,7 @@ export default function LightningBoxRegistration({ navigation }: ILightningBoxPr

useLayoutEffect(() => {
navigation.setOptions({
headerTitle: t("title"),
headerTitle: t("generic.lightningBox", { ns: namespaces.common }),
headerBackTitle: t("buttons.back", { ns: namespaces.common }),
headerShown: true,
});
Expand All @@ -59,17 +59,19 @@ export default function LightningBoxRegistration({ navigation }: ILightningBoxPr
return (
<Container>
<Content centered>
<H1 style={{ marginBottom: 10 }}>Lightning Address</H1>
<H1 style={{ marginBottom: 10 }}>
{t("generic.lightningAddress", { ns: namespaces.common })}
</H1>

<Text>Your Lightning Address by Lightning Box is:</Text>
<Text>{t("yourLightningAddress")}</Text>
<View style={{ width: "89%", marginBottom: 16 }} testID="payment-request-string">
<CopyAddress text={lightningBoxAddress} onPress={onPressLightningAddress} />
</View>
{/* <Text>Message to payer: {lightningBoxLnurlPayDesc}</Text> */}
{showQrCode && <QrCode size={150} border={15} data={lud17} onPress={onPressQrCode} />}
{!showQrCode && (
<Button onPress={onPressShowQrCode}>
<Text>Show QR code</Text>
<Text>{t("showQrCode")}</Text>
</Button>
)}
</Content>
Expand Down
70 changes: 34 additions & 36 deletions src/windows/LightningBox/LightningBoxRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Container from "../../components/Container";
import { StackNavigationProp } from "@react-navigation/stack";
import { signMessageNodePubkey } from "../../lndmobile/wallet";
import { getUnixTime } from "date-fns";
import { bytesToHexString, stringToUint8Array, timeout, toast } from "../../utils";
import { bytesToHexString, stringToUint8Array, toast } from "../../utils";
import { useTranslation } from "react-i18next";
import { namespaces } from "../../i18n/i18n.constants";
import { NativeModules, Platform, StyleSheet } from "react-native";
Expand Down Expand Up @@ -62,7 +62,7 @@ interface ILightningBoxProps {
}
export default function LightningBoxRegistration({ navigation }: ILightningBoxProps) {
const lightningBoxServer = useStoreState((store) => store.settings.lightningBoxServer);
const t = useTranslation(namespaces.lightningBox.manage).t;
const t = useTranslation(namespaces.lightningBox.registration).t;
const tSettings = useTranslation(namespaces.settings.settings).t;

const [loading, setLoading] = useState(false);
Expand Down Expand Up @@ -115,14 +115,18 @@ export default function LightningBoxRegistration({ navigation }: ILightningBoxPr
}
}
} catch (error: any) {
toast("Error: " + error.message, undefined, "danger");
toast(
t("msg.error", { ns: namespaces.common }) + ": " + error.message,
undefined,
"danger",
);
}
})();
}, []);

useLayoutEffect(() => {
navigation.setOptions({
headerTitle: t("title"),
headerTitle: t("generic.lightningBox", { ns: namespaces.common }),
headerBackTitle: t("buttons.back", { ns: namespaces.common }),
headerShown: true,
});
Expand Down Expand Up @@ -159,7 +163,7 @@ export default function LightningBoxRegistration({ navigation }: ILightningBoxPr
}
} catch (error) {
console.error(error);
toast("Error: " + error.message, undefined, "danger");
toast(t("msg.error", { ns: namespaces.common }) + ": " + error.message, undefined, "danger");
setLoading(false);
}
};
Expand Down Expand Up @@ -204,53 +208,43 @@ export default function LightningBoxRegistration({ navigation }: ILightningBoxPr
return (
<Container>
<Content>
<H1>📥 Lightning Box</H1>
<H1>📥 {t("generic.lightningBox", { ns: namespaces.common })}</H1>
<View style={{ marginTop: 10 }}>
<Text style={style.p}>Welcome to the Lightning Box registration.</Text>
<Text style={style.p}>
Lightning Box is a Lightning Address service provider that forwards payment requests
directly to the phone, giving you a self-custodial Lightning Address for mobile devices.
</Text>
<Text style={style.p}>
This service is dependent on persistent mode, because the app must stay active to
receive incoming payments. Please make sure that battery optimization is turned off on
your device. Otherwise this service may not work.
</Text>
<Text style={style.p}>
The service is free to use. However, due to technical reasons it currently requires a
channel with the Lightning Box provider. It's currently not possible to change your
Lightning Address after you have chosen one.
</Text>
<Text style={style.p}>{t("info.welcome")}</Text>
<Text style={style.p}>{t("info.whatIs")}</Text>
<Text style={style.p}>{t("info.persistentMode")}</Text>
<Text style={style.p}>{t("info.currentRules")}</Text>
{/* <Text style={style.p}>Follow the steps below in order to register your account.</Text> */}
</View>
<View style={style.prerequisites}>
<H2>Prerequisites</H2>
<H2>{t("prerequisites.prerequisites")}</H2>
<List style={style.list}>
<ListItem style={style.listItem} icon={true}>
<Left>
<Icon style={style.icon} type="Entypo" name="magnifying-glass" />
</Left>
<Body>
{lnboxIsEligible == null && (
<Text>{/*t("prerequisites.eligibility")*/}Checking eligibility...</Text>
)}
{lnboxIsEligible == null && <Text>{t("prerequisites.checkingEligibility")}</Text>}
{lnboxIsEligible === true && (
<>
<Text>Eligible</Text>
<Text note={true}>You have a channel with the Lightning Box service.</Text>
<Text>{t("prerequisites.eligible")}</Text>
<Text note={true}>{t("prerequisites.youHaveChannel")}</Text>
</>
)}
{lnboxIsEligible === false && (
<>
<Text>Not eligible</Text>
<Text note={true}>Reason: {lnboxNotEligibleReason}</Text>
<Text>{t("prerequisites.notEligible")}</Text>
<Text note={true}>
{t("generic.reason", {
ns: namespaces.common,
reason: lnboxNotEligibleReason,
})}
</Text>
</>
)}
</Body>
<Right>
{lnboxIsEligible !== null && (
<CheckBox disabled checked={lnboxIsEligible} onPress={undefined} />
)}
{lnboxIsEligible !== null && <CheckBox disabled checked={lnboxIsEligible} />}
</Right>
</ListItem>

Expand All @@ -277,9 +271,9 @@ export default function LightningBoxRegistration({ navigation }: ILightningBoxPr
</View>

<View style={style.prerequisites}>
<H2>Registration</H2>
<H2>{t("registration.registration")}</H2>
<Item>
<Label style={{ width: 95 }}>Address</Label>
<Label style={{ width: 95 }}>{t("registration.fields.address")}</Label>
<Input
autoCapitalize="none"
secureTextEntry={true}
Expand All @@ -292,7 +286,7 @@ export default function LightningBoxRegistration({ navigation }: ILightningBoxPr
<Text>@blixtwallet.com</Text>
</Item>
<Item>
<Label style={{ width: 95 }}>Message to the payer</Label>
<Label style={{ width: 95 }}>{t("registration.fields.messageToPayer")}</Label>
<Input value={lnurlpDesc} onChangeText={setLnurlpDesc} maxLength={64} />
</Item>
<Text></Text>
Expand All @@ -306,7 +300,11 @@ export default function LightningBoxRegistration({ navigation }: ILightningBoxPr
primary={true}
disabled={!(lnboxIsEligible && name && !loading)}
>
{loading ? <Spinner color={blixtTheme.light} /> : <Text>Register</Text>}
{loading ? (
<Spinner color={blixtTheme.light} />
) : (
<Text>{t("registration.register")}</Text>
)}
</Button>
</Content>
</Container>
Expand Down
1 change: 0 additions & 1 deletion src/windows/LightningBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default function LightningBox() {
// We use the setting in order to decide whether the user shuold go to the
// registration screen or info screen.
const lightningBoxAddress = useStoreState((store) => store.settings.lightningBoxAddress);
console.log("hej lnbox", lightningBoxAddress);

const screenOptions: StackNavigationOptions = {
...useStackNavigationOptions(),
Expand Down

1 comment on commit ef5ac7e

@vercel
Copy link

@vercel vercel bot commented on ef5ac7e Nov 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blixt-wallet – ./

blixt-wallet-git-master-hsjoberg.vercel.app
blixt-wallet-hsjoberg.vercel.app

Please sign in to comment.