Browse Source

Minor i18n fixes (#663)

* i18n fixes

Add PKI Backup Reminder dialog + ensure en-US is UI default

* Revert edits to i18n components
pull/670/head
Jeremy Gallant 1 year ago
committed by GitHub
parent
commit
ccc4202aa4
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      src/components/KeyBackupReminder.tsx
  2. 14
      src/core/hooks/useKeyBackupReminder.tsx
  3. 1
      src/i18n/locales/en/common.json
  4. 8
      src/i18n/locales/en/dialog.json

2
src/components/KeyBackupReminder.tsx

@ -7,7 +7,7 @@ export const KeyBackupReminder = () => {
const { t } = useTranslation("dialog"); const { t } = useTranslation("dialog");
useBackupReminder({ useBackupReminder({
message: t("pkiBackup.description"), message: t("pkiBackupReminder.description"),
onAccept: () => setDialogOpen("pkiBackup", true), onAccept: () => setDialogOpen("pkiBackup", true),
enabled: true, enabled: true,
}); });

14
src/core/hooks/useKeyBackupReminder.tsx

@ -2,6 +2,7 @@ import { Button } from "@components/UI/Button.tsx";
import { useCallback, useEffect, useRef } from "react"; import { useCallback, useEffect, useRef } from "react";
import { useToast } from "@core/hooks/useToast.ts"; import { useToast } from "@core/hooks/useToast.ts";
import useLocalStorage from "@core/hooks/useLocalStorage.ts"; import useLocalStorage from "@core/hooks/useLocalStorage.ts";
import { useTranslation } from "react-i18next";
interface UseBackupReminderOptions { interface UseBackupReminderOptions {
reminderInDays?: number; reminderInDays?: number;
@ -36,6 +37,8 @@ export function useBackupReminder({
onAccept = () => {}, onAccept = () => {},
reminderInDays = REMINDER_DAYS_ONE_WEEK, reminderInDays = REMINDER_DAYS_ONE_WEEK,
}: UseBackupReminderOptions) { }: UseBackupReminderOptions) {
const { t } = useTranslation("dialog");
const { toast } = useToast(); const { toast } = useToast();
const toastShownRef = useRef(false); const toastShownRef = useRef(false);
const [reminderState, setReminderState] = useLocalStorage< const [reminderState, setReminderState] = useLocalStorage<
@ -59,7 +62,7 @@ export function useBackupReminder({
toastShownRef.current = true; toastShownRef.current = true;
const { dismiss } = toast({ const { dismiss } = toast({
title: "Backup Reminder", title: t("pkiBackupReminder.title"),
duration: TOAST_DURATION, duration: TOAST_DURATION,
delay: TOAST_APPEAR_DELAY, delay: TOAST_APPEAR_DELAY,
description: message, description: message,
@ -75,7 +78,10 @@ export function useBackupReminder({
setReminderExpiry(reminderInDays); setReminderExpiry(reminderInDays);
}} }}
> >
Remind me in {reminderInDays} day{reminderInDays > 1 ? "s" : ""} {t("pkiBackupReminder.remindLaterPrefix")} {reminderInDays}{" "}
{reminderInDays > 1
? t("common:unit.day.plural").toLowerCase()
: t("common:unit.day.one").toLowerCase()}
</Button> </Button>
<Button <Button
type="button" type="button"
@ -86,7 +92,7 @@ export function useBackupReminder({
setReminderExpiry(REMINDER_DAYS_FOREVER); setReminderExpiry(REMINDER_DAYS_FOREVER);
}} }}
> >
Never remind me {t("pkiBackupReminder.remindNever")}
</Button> </Button>
</div> </div>
<Button <Button
@ -99,7 +105,7 @@ export function useBackupReminder({
setReminderExpiry(REMINDER_DAYS_ONE_YEAR); setReminderExpiry(REMINDER_DAYS_ONE_YEAR);
}} }}
> >
Back up now {t("pkiBackupReminder.backupNow")}
</Button> </Button>
</div> </div>
), ),

1
src/i18n/locales/en/common.json

@ -54,6 +54,7 @@
"suffix": "ms" "suffix": "ms"
}, },
"second": { "one": "Second", "plural": "Seconds" }, "second": { "one": "Second", "plural": "Seconds" },
"day": { "one": "Day", "plural": "Days" },
"snr": "SNR", "snr": "SNR",
"volt": { "one": "Volt", "plural": "Volts", "suffix": "V" }, "volt": { "one": "Volt", "plural": "Volts", "suffix": "V" },
"record": { "one": "Records", "plural": "Records" } "record": { "one": "Records", "plural": "Records" }

8
src/i18n/locales/en/dialog.json

@ -93,7 +93,6 @@
"unignoreNode": "Unignore node" "unignoreNode": "Unignore node"
}, },
"pkiBackup": { "pkiBackup": {
"description": "We recommend backing up your key data regularly. Would you like to back up now?",
"loseKeysWarning": "If you lose your keys, you will need to reset your device.", "loseKeysWarning": "If you lose your keys, you will need to reset your device.",
"secureBackup": "Its important to backup your public and private keys and store your backup securely!", "secureBackup": "Its important to backup your public and private keys and store your backup securely!",
"footer": "=== END OF KEYS ===", "footer": "=== END OF KEYS ===",
@ -103,6 +102,13 @@
"fileName": "meshtastic_keys_{{longName}}_{{shortName}}.txt", "fileName": "meshtastic_keys_{{longName}}_{{shortName}}.txt",
"title": "Backup Keys" "title": "Backup Keys"
}, },
"pkiBackupReminder": {
"description": "We recommend backing up your key data regularly. Would you like to back up now?",
"title": "Backup Reminder",
"remindLaterPrefix": "Remind me in",
"remindNever": "Never remind me",
"backupNow": "Back up now"
},
"pkiRegenerate": { "pkiRegenerate": {
"description": "Are you sure you want to regenerate key pair?", "description": "Are you sure you want to regenerate key pair?",
"title": "Regenerate Key Pair" "title": "Regenerate Key Pair"

Loading…
Cancel
Save