wengz-notifications-locale
Adds or fixes Wengz email, in-app, or SSE notifications and locale handling. Use when editing src/lib/notifications, user-locale, cron notify paths, or when Arabic/English copy is wrong for recipients
SKILL.md.cursor/skills/wengz-notifications-locale/SKILL.md
GitHubWengz notifications and locale
Prerequisites
docs/ADVANCED_TECHNICAL.md§ Internationalization + recipient notify localedocs/ADVANCED_BUSINESS.md§ Notifications- Code:
src/lib/notifications/index.ts,src/lib/user-locale.ts,src/lib/error-handler.ts
Rules
- Recipient wins — Single-user
notify*helpers must calllocaleForUser(userId)/getPreferredLocaleForUser. Never pass staffctx.localeas the client/provider language. - Staff fan-out —
notifyStaffByRolesbuilds once per locale group from each admin’spreferredLocale. - Account emails by address —
sendAccountApprovedEmail/Rejectedresolve locale via email → user row. - UI toasts — Client components:
useTranslations+showError/showSuccessfrom@/lib/error-handlerwitht. - Both languages — New
notifications.*/errors.*keys inmessages/en.jsonandmessages/ar.json. - Cron dedupe — Stable
Notification.type(e.g.subscription_expiring), not English title strings. - SSE — Prefer
sseI18nkeys when the client can re-translate; still persist a sensible title/message for the feed.
Adding a notification
- Add translation keys (en + ar).
- Add email template helper in
src/lib/notifications/email.tsif email is needed. - Export
notifyXthat resolves recipient locale first. - Call from router/lib/cron; do not inline HTML in routers.
- Cover staff vs client/provider audience correctly (roles).
Anti-patterns
- Using
ctx.localefor “the other party” on approve/reject/status. - Deduping cron notifies by translated title.
- Hardcoding English-only admin emails.