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.
This commit is contained in:
47
convex/users.ts
Normal file
47
convex/users.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
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;
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user