Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 1, 2025

This PR implements the requested change to use Ember Intl style translation keys for notification messages instead of hardcoded English strings, enabling proper internationalization support for the frontend application.

Changes Made

Database Schema

  • Added migration to create message_key (string) and message_params (jsonb) columns on the notifications table
  • Added missing badge award types to the notification enum: dragionfruit_badge_award, blueberrinies_badge_award, beamsprout_badge_award

Notification Model

Completely refactored the set_message method to use structured translation keys:

Before:

when "strawberry_badge_award"
  "#{self.user.username} got the strawbur badge!"

After:

when "strawberry_badge_award"
  set_translation_key("notifications.badge_award.strawberry", { username: self.user.username })

API Response

Updated the NotificationSerializer to include the new fields:

  • message_key: Translation key (e.g., "notifications.badge_award.strawberry")
  • message_params: Parameters for interpolation (e.g., { "username": "mcfiredrill" })
  • message: Kept for backward compatibility (empty for new notifications)

Translation Key Structure

All notification types now use consistent dot-separated keys:

  • Badge awards: notifications.badge_award.{fruit_type}
  • User progress: notifications.level_up, notifications.experience_point_award
  • Fruit tickets: notifications.fruit_ticket_gift, notifications.supporter_fruit_ticket_stipend
  • Content events: notifications.new_thread, notifications.wiki_page_update
  • Shrimpo events: notifications.shrimpo_started, notifications.shrimpo_entry

Frontend Integration

The frontend app can now use these translation keys with Ember Intl:

const translatedMessage = this.intl.t(notification.message_key, notification.message_params);

Backward Compatibility

  • Existing notifications retain their original English messages in the message field
  • New notifications have empty message field but populated message_key and message_params
  • Frontend should prioritize translation keys when available, fallback to legacy message field

Documentation

Added comprehensive documentation in docs/notification_translations.md listing all translation keys and their required parameters for the frontend team.

Testing

Created test coverage for the new translation key functionality to ensure proper key assignment and parameter extraction.

Fixes the internationalization requirement by moving message composition to the frontend where proper translation management can be handled by the datafruits/datafruits application.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits September 1, 2025 17:47
Co-authored-by: mcfiredrill <66243+mcfiredrill@users.noreply.github.com>
Co-authored-by: mcfiredrill <66243+mcfiredrill@users.noreply.github.com>
Copilot AI changed the title [WIP] change the messages in the notifications model to use ember intl style translation keys. we will manage the actual translation keys on the frontend app datafruits/datafruits. Convert notification messages to use Ember Intl translation keys Sep 1, 2025
Copilot AI requested a review from mcfiredrill September 1, 2025 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants