Files
lemonspace_app/convex/users.ts
Matthias Meister 79d9092d43 Implement internationalization support across components
- Integrated `next-intl` for toast messages and locale handling in various components, including `Providers`, `CanvasUserMenu`, and `CreditOverview`.
- Replaced hardcoded strings with translation keys to enhance localization capabilities.
- Updated `RootLayout` to dynamically set the language attribute based on the user's locale.
- Ensured consistent user feedback through localized toast messages in actions such as sign-out, canvas operations, and billing notifications.
2026-04-01 18:16:52 +02:00

48 lines
1.1 KiB
TypeScript

import { mutation } from "./_generated/server";
import { v } from "convex/values";
import { requireAuth } from "./helpers";
export const setLocale = mutation({
args: {
locale: v.union(v.literal("de"), v.literal("en")),
},
handler: async (ctx, args) => {
const { userId } = await requireAuth(ctx);
const existing = await ctx.db
.query("userSettings")
.withIndex("by_user", (q) => q.eq("userId", userId))
.unique();
const now = Date.now();
if (existing) {
await ctx.db.patch(existing._id, {
locale: args.locale,
updatedAt: now,
});
} else {
await ctx.db.insert("userSettings", {
userId,
locale: args.locale,
createdAt: now,
updatedAt: now,
});
}
},
});
export const getLocale = mutation({
args: {},
handler: async (ctx) => {
const { userId } = await requireAuth(ctx);
const existing = await ctx.db
.query("userSettings")
.withIndex("by_user", (q) => q.eq("userId", userId))
.unique();
return existing?.locale ?? null;
},
});