add string translations in german
This commit is contained in:
1 parent
365fcf0cae
commit
5bf3f8694c
12 files changed
+126
-112
No files matched your search
+19
-19
@@ -25,7 +25,7 @@ const readBody = async (req) =>
|
||||
req.on("data", (chunk) => {
|
||||
raw += chunk;
|
||||
if (raw.length > 1_000_000) {
|
||||
reject(new Error("Request body too large"));
|
||||
reject(new Error("Anfrage ist zu gross."));
|
||||
req.destroy();
|
||||
}
|
||||
});
|
||||
@@ -37,7 +37,7 @@ const readBody = async (req) =>
|
||||
try {
|
||||
resolve(JSON.parse(raw));
|
||||
} catch {
|
||||
reject(new Error("Invalid JSON"));
|
||||
reject(new Error("Ungültiges JSON."));
|
||||
}
|
||||
});
|
||||
req.on("error", reject);
|
||||
@@ -130,7 +130,7 @@ const authenticate = (req) => {
|
||||
const requireAuth = (req, res) => {
|
||||
const auth = authenticate(req);
|
||||
if (!auth) {
|
||||
json(res, 401, { error: "Please log in to continue." });
|
||||
json(res, 401, { error: "Bitte melde dich an, um fortzufahren." });
|
||||
return null;
|
||||
}
|
||||
return auth;
|
||||
@@ -175,7 +175,7 @@ const getAvailableDiscounts = (userId, rows) => {
|
||||
type: "discovery",
|
||||
creditId: discovery.id,
|
||||
amount_cents: Math.min(discovery.amount_cents, fullTotal),
|
||||
label: "Discovery Set credit",
|
||||
label: "Discovery-Set-Gutschrift",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ const getAvailableDiscounts = (userId, rows) => {
|
||||
slug: row.slug,
|
||||
product_id: row.product_id,
|
||||
amount_cents: Math.min(sample.amount_cents, row.price_cents * row.quantity),
|
||||
label: `${row.name.replace(" Full Size", "")} sample credit`,
|
||||
label: `Proben-Gutschrift für ${row.name.replace(" 50 ml Flakon", "")}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -355,13 +355,13 @@ const register = async (req, res) => {
|
||||
const surname = String(body.surname || "").trim();
|
||||
|
||||
if (!firstName || !surname || !email || !password) {
|
||||
json(res, 400, { error: "First name, surname, email, and password are required." });
|
||||
json(res, 400, { error: "Vorname, Nachname, E-Mail und Passwort sind erforderlich." });
|
||||
return;
|
||||
}
|
||||
|
||||
const existing = db.prepare("SELECT id FROM users WHERE email = ?").get(email);
|
||||
if (existing) {
|
||||
json(res, 409, { error: "An account with this email already exists." });
|
||||
json(res, 409, { error: "Mit dieser E-Mail existiert bereits ein Konto." });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ const login = async (req, res) => {
|
||||
const user = db.prepare("SELECT * FROM users WHERE email = ?").get(email);
|
||||
|
||||
if (!user || !verifyPassword(password, user.password_salt, user.password_hash)) {
|
||||
json(res, 401, { error: "Invalid email or password." });
|
||||
json(res, 401, { error: "E-Mail oder Passwort ist ungültig." });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ const patchProfile = async (req, res, user) => {
|
||||
});
|
||||
|
||||
if (!firstName || !surname) {
|
||||
json(res, 400, { error: "First name and surname are required." });
|
||||
json(res, 400, { error: "Vorname und Nachname sind erforderlich." });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ const addCartItem = async (req, res, user) => {
|
||||
const quantity = Math.max(1, Number(body.quantity || 1));
|
||||
const product = db.prepare("SELECT * FROM products WHERE id = ?").get(productId);
|
||||
if (!product) {
|
||||
json(res, 404, { error: "Product not found." });
|
||||
json(res, 404, { error: "Produkt nicht gefunden." });
|
||||
return;
|
||||
}
|
||||
const timestamp = now();
|
||||
@@ -472,7 +472,7 @@ const addCartItem = async (req, res, user) => {
|
||||
).run(user.id, productId, quantity, timestamp, timestamp);
|
||||
json(res, 200, {
|
||||
cart: getCart(user.id),
|
||||
message: `${quantity} x ${product.name} added.`,
|
||||
message: `${quantity} x ${product.name} wurde in den Warenkorb gelegt.`,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -480,7 +480,7 @@ const patchCartItem = async (req, res, user, productId) => {
|
||||
const body = await readBody(req);
|
||||
const quantity = Number(body.quantity);
|
||||
if (!Number.isFinite(quantity)) {
|
||||
json(res, 400, { error: "Quantity is required." });
|
||||
json(res, 400, { error: "Die Menge ist erforderlich." });
|
||||
return;
|
||||
}
|
||||
if (quantity <= 0) {
|
||||
@@ -502,7 +502,7 @@ const checkout = async (req, res, user) => {
|
||||
const body = await readBody(req);
|
||||
const rows = getCartRows(user.id);
|
||||
if (rows.length === 0) {
|
||||
json(res, 400, { error: "Your cart is empty." });
|
||||
json(res, 400, { error: "Dein Warenkorb ist leer." });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -514,11 +514,11 @@ const checkout = async (req, res, user) => {
|
||||
};
|
||||
const paymentMethod = String(body.payment_method || body.paymentMethod || "").trim();
|
||||
if (!addressFields.street_name || !addressFields.house_number || !addressFields.zip_code || !addressFields.city) {
|
||||
json(res, 400, { error: "Street name, house number, ZIP code, and city are required." });
|
||||
json(res, 400, { error: "Strasse, Hausnummer, PLZ und Ort sind erforderlich." });
|
||||
return;
|
||||
}
|
||||
if (!["Bill", "Card", "Twint", "PayPal"].includes(paymentMethod)) {
|
||||
json(res, 400, { error: "Choose a payment method." });
|
||||
json(res, 400, { error: "Wähle eine Zahlungsmethode." });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -611,7 +611,7 @@ const subscribeProduct = async (req, res, user) => {
|
||||
const type = String(body.type || "restock").trim();
|
||||
const product = db.prepare("SELECT * FROM products WHERE id = ?").get(productId);
|
||||
if (!product) {
|
||||
json(res, 404, { error: "Product not found." });
|
||||
json(res, 404, { error: "Produkt nicht gefunden." });
|
||||
return;
|
||||
}
|
||||
db.prepare(
|
||||
@@ -620,7 +620,7 @@ const subscribeProduct = async (req, res, user) => {
|
||||
).run(user.id, productId, type, now());
|
||||
json(res, 200, {
|
||||
ok: true,
|
||||
message: `${product.name} ${type} subscription saved.`,
|
||||
message: `${product.name}: Benachrichtigung gespeichert.`,
|
||||
subscriptions: getProductSubscriptions(user.id),
|
||||
});
|
||||
};
|
||||
@@ -719,13 +719,13 @@ const route = async (req, res) => {
|
||||
return deleteCartItem(res, user, decodeURIComponent(itemMatch[1]));
|
||||
}
|
||||
|
||||
json(res, 404, { error: "Route not found." });
|
||||
json(res, 404, { error: "Route nicht gefunden." });
|
||||
};
|
||||
|
||||
createServer((req, res) => {
|
||||
route(req, res).catch((error) => {
|
||||
console.error(error);
|
||||
json(res, 500, { error: "Server error." });
|
||||
json(res, 500, { error: "Serverfehler." });
|
||||
});
|
||||
}).listen(PORT, () => {
|
||||
console.log(`Shop API listening on http://localhost:${PORT}`);
|
||||
|
||||
Reference in new issue
Block a user