Skip to content

Commit

Permalink
Missing translation strings (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmintey authored Dec 21, 2024
2 parents 8212482 + 5e20c8c commit 922044b
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 82 deletions.
21 changes: 19 additions & 2 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"toggle-manager": "{isManager, select, true {remove} other {add}} {user} as manager",
"toggle-password-visibility": "toggle password visibility",
"two-people-looking-in-an-empty-box": "Two people looking in an empty box",
"upload-profile-image": "upload profile image"
"upload-profile-image": "upload profile image",
"wishlist-logo": "Wishlist Logo"
},
"admin": {
"about": "About",
Expand Down Expand Up @@ -75,7 +76,9 @@
"version": "Version: <a href=\"https://github.com/cmintey/wishlist/releases/tag/{version}\">{version}</a>",
"wishlist-mode": "Wishlist Mode",
"wishlist-mode-alert": "There are other members in this group, you cannot switch the mode until you remove all but one member.",
"wishlist-mode-registry": "Registry"
"wishlist-mode-display-text": "In 'Wishlist' mode, you can have multiple users and lists and claim items from other users. In 'Registry' mode, you have a single list which you can publicly share.",
"wishlist-mode-registry": "Registry",
"wishlist-mode-wishlist": "Wishlist"
},
"app": {
"home": "Home",
Expand Down Expand Up @@ -109,6 +112,19 @@
"username": "Username",
"your-password-was-reset": "Your password was reset."
},
"email": {
"invite-body": "You've been invited to join Wishlist! To accept the invitation, click on the link below.",
"invite-button": "Join Wishlist",
"invite-fallback-text": "Somebody has invited you to join their Wishlist! Follow the link to signup: {url}",
"invite-footer": "If you do not wish to join or believe this email to be sent in error, then you can ignore this email.",
"invite-subject": "Wishlist Invite",
"invite-title": "Welcome to Wishlist!",
"pw-reset-body": "If you requested a password reset, click the link below to complete the process. If you didn't make this request, then you can safely ignore this email.",
"pw-reset-fallback-text": "Follow the link to reset your password {resetUrl}",
"pw-reset-title": "Reset Password",
"test-body": "If you're reading this, then congratulations! Email configuration seems to have been set up properly!",
"test-subject": "Test from Wishlist"
},
"errors": {
"asset-not-found": "Asset not found",
"cannot-delete-default-group": "Cannot Delete Default Group",
Expand Down Expand Up @@ -205,6 +221,7 @@
"submit": "Submit",
"success": "Success!",
"this-invite-link-is-only-valid-for-one-signup": "This invite link is only valid for one signup",
"toggle-dark-mode": "Toggle light or dark mode",
"update": "Update",
"user": "User",
"user-count": "User Count",
Expand Down
1 change: 0 additions & 1 deletion src/lib/components/admin/Groups.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
}
await invalidateAll();
},
// Optionally override the button text
buttonTextCancel: $t("general.cancel"),
buttonTextSubmit: $t("general.submit")
};
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/admin/SettingsForm/ListMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
{#if disabled}
<Alert type="info">{$t("admin.wishlist-mode-alert")}</Alert>
{/if}
<span>{$t("admin.wishlist-mode-display-text")}</span>
<select id="listMode" name="listMode" class="select w-fit min-w-64" bind:value={mode}>
<option value="standard">Wishlist</option>
<option value="standard">{$t("admin.wishlist-mode-wishlist")}</option>
{#if !disabled}
<option value="registry">{$t("admin.wishlist-mode-registry")}</option>
{/if}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/admin/SettingsForm/SMTP.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
bind:value={user}
/>
</label>
<PasswordInput id="smtpPass" name="smtpPass" label="Password" required bind:value={pass} />
<PasswordInput id="smtpPass" name="smtpPass" label={$t("auth.password")} required bind:value={pass} />
<label for="smtpFrom">
<span>{$t("admin.smtp-from-email")}</span>
<input
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/navigation/NavMenu/NavMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<li>
<div class="flex w-full justify-around">
<p>{$t("general.mode")}</p>
<LightSwitch />
<LightSwitch title={$t("general.toggle-dark-mode")} />
</div>
</li>
</ul>
Expand Down
13 changes: 9 additions & 4 deletions src/lib/components/wishlists/ItemCard/ItemCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
const confirmDeleteModal: ModalSettings = {
type: "confirm",
title: "Please Confirm",
title: $t("general.please-confirm"),
body: $t("wishes.are-you-sure-you-wish-to-delete-name", { values: { name: item.name } }),
// confirm = TRUE | cancel = FALSE
response: async (r: boolean) => {
Expand All @@ -105,7 +105,9 @@
triggerErrorToast();
}
}
}
},
buttonTextCancel: $t("general.cancel"),
buttonTextConfirm: $t("general.confirm")
};
const approvalModal = (approve: boolean): ModalSettings => ({
Expand All @@ -127,7 +129,9 @@
triggerErrorToast();
}
}
}
},
buttonTextCancel: $t("general.cancel"),
buttonTextConfirm: $t("general.confirm")
});
const handleDelete = async () => modalStore.trigger(confirmDeleteModal);
Expand Down Expand Up @@ -170,7 +174,8 @@
triggerErrorToast();
}
}
}
},
buttonTextCancel: $t("general.cancel")
});
}
drawerStore.close();
Expand Down
55 changes: 42 additions & 13 deletions src/lib/server/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ import { readFile } from "fs";
import type Mail from "nodemailer/lib/mailer";
import { getConfig } from "$lib/server/config";
import { env } from "$env/dynamic/private";
import { getFormatter } from "$lib/i18n";

type TemplateData = {
type InviteTemplateData = {
url: string;
baseUrl: string;
wishlistLogoText: string;
previewText: string;
titleText: string;
bodyText: string;
buttonText: string;
footerText: string;
};

let passResetTempl: HandlebarsTemplateDelegate<TemplateData>;
let inviteTempl: HandlebarsTemplateDelegate<TemplateData>;
type PasswordResetTemplateData = Omit<InviteTemplateData, "footerText">;

let passResetTempl: HandlebarsTemplateDelegate<PasswordResetTemplateData>;
let inviteTempl: HandlebarsTemplateDelegate<InviteTemplateData>;

readFile("templates/password-reset.html", "utf-8", (err, data) => {
if (err) {
Expand Down Expand Up @@ -79,30 +88,50 @@ const sendEmail = async (options: Mail.Options) => {
});
};

export const sendSignupLink = async (to: string, url: string) => {
const html = inviteTempl({ url, baseUrl: env.ORIGIN || "http://localhost:5173" });
export const sendSignupLink = async (to: string, inviteUrl: string) => {
const $t = await getFormatter();
const html = inviteTempl({
url: inviteUrl,
baseUrl: env.ORIGIN || "http://localhost:5173",
wishlistLogoText: $t("a11y.wishlist-logo"),
previewText: $t("email.invite-title"),
titleText: $t("email.invite-title"),
bodyText: $t("email.invite-body"),
buttonText: $t("email.invite-button"),
footerText: $t("email.invite-footer")
});
return await sendEmail({
to,
subject: "Wishlist Invite",
subject: $t("email.invite-subject"),
html,
text: `Somebody has invited you to join their Wishlist! Follow the link to signup: ${url}`
text: $t("email.invite-fallback-text", { values: { url: inviteUrl } })
});
};

export const sendPasswordReset = async (to: string, url: string) => {
const html = passResetTempl({ url, baseUrl: env.ORIGIN || "http://localhost:5173" });
export const sendPasswordReset = async (to: string, resetUrl: string) => {
const $t = await getFormatter();
const html = passResetTempl({
url: resetUrl,
baseUrl: env.ORIGIN || "http://localhost:5173",
wishlistLogoText: $t("a11y.wishlist-logo"),
previewText: $t("email.pw-reset-title"),
titleText: $t("email.pw-reset-title"),
bodyText: $t("email.pw-reset-body"),
buttonText: $t("email.pw-reset-title")
});
return await sendEmail({
to,
subject: "Password Reset",
subject: "Wishlist | " + $t("email.pw-reset-title"),
html,
text: `Follow the link to reset your password ${url}`
text: $t("email.pw-reset-fallback-text", { values: { url: resetUrl } })
});
};

export const sendTest = async (to: string) => {
const $t = await getFormatter();
return await sendEmail({
to,
subject: "Test from Wishlist",
text: "If you're reading this, then congratulations! Email configuration seems to have been set up properly!"
subject: $t("email.test-subject"),
text: $t("email.test-body")
});
};
11 changes: 8 additions & 3 deletions src/routes/admin/groups/[groupId]/members/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
await groupAPI.addMember(userId);
invalidateAll();
}
}
},
buttonTextCancel: $t("general.cancel")
};
const toggleManager = async (userId: string, isManager: boolean) => {
Expand Down Expand Up @@ -61,7 +62,9 @@
await groupAPI.removeMember(userId);
await invalidateAll();
}
},
buttonTextCancel: $t("general.cancel"),
buttonTextConfirm: $t("general.confirm")
});
};
Expand All @@ -87,7 +90,9 @@
await invalidateAll();
goto("/");
}
}
},
buttonTextCancel: $t("general.cancel"),
buttonTextConfirm: $t("general.confirm")
});
};
</script>
Expand Down
4 changes: 3 additions & 1 deletion src/routes/admin/users/[username]/+page@.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
});
}
}
}
},
buttonTextCancel: $t("general.cancel"),
buttonTextConfirm: $t("general.confirm")
};
modalStore.trigger(settings);
};
Expand Down
2 changes: 1 addition & 1 deletion src/routes/setup-wizard/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<div transition:fade>
<div class="flex flex-col items-center space-y-4">
<h1 class="h1">{$t("setup.create-your-account")}</h1>
<span>$t('setup.first-account-admin')</span>
<span>{$t("setup.first-account-admin")}</span>
</div>
</div>
{/if}
4 changes: 2 additions & 2 deletions src/routes/wishlists/[username]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@
<div class="flex flex-row space-x-2 pb-4">
{#if publicListUrl}
<div class="flex flex-row">
<TokenCopy btnStyle="btn-icon-sm" url={publicListUrl?.href}>$t('wishes.public-url')</TokenCopy>
<TokenCopy btnStyle="btn-icon-sm" url={publicListUrl?.href}>{$t("wishes.public-url")}</TokenCopy>
</div>
{:else}
<button class="variant-ringed-surface btn btn-sm" onclick={getOrCreatePublicList}>
$t('wishes.share')
{$t("wishes.share")}
</button>
{/if}
</div>
Expand Down
Loading

0 comments on commit 922044b

Please sign in to comment.