Skip to content

chore(subscription): localize slack notification messages - #2778

Merged
t-kikuc merged 3 commits into
mainfrom
chore/translate-slack-notification
Aug 21, 2026
Merged

chore(subscription): localize slack notification messages#2778
t-kikuc merged 3 commits into
mainfrom
chore/translate-slack-notification

Conversation

@kimurakazuhiro-c

Copy link
Copy Markdown
Collaborator

What this PR does

Replaces the hardcoded Japanese-only Slack notification messages with the shared locale.Localizer, so feature-stale, running-experiment, and MAU-count notifications are rendered in the recipient's language.

Background / Why this PR is needed

pkg/subscription/sender/notifier/message.go held the notification text as Japanese string literals and had a localizedMessage() helper that ignored the loc argument entirely — every call site passed locale.Ja with a // handle loc if multi-lang is necessary note. Meanwhile the rest of the codebase already resolves messages through locale.Localizer backed by pkg/locale/localizedata/*.yaml, and createAttachment already receives a localizer. This PR removes the parallel mechanism and moves these messages onto the standard path so English recipients get English text.

Points

  • message.go is deleted outright, along with msgType, errUnknownMsgType, and the *errdetails.LocalizedMessage values. Nothing else referenced them.
  • The three create*Attachment methods keep their error return even though the localizer path itself no longer fails — createFeatureStaleAttachment and createExperimentRunningAttachment still build URLs that can error, and keeping the signature uniform avoids churn in createAttachment.
  • MustLocalize/MustLocalizeWithTemplate are used rather than the error-returning variants, matching how the rest of the codebase consumes the localizer.
  • The experiment days-left string is localized as a whole phrase ({{ .Field_1 }} days left / 残り {{ .Field_1 }} 日) rather than interpolating a translated "days" word, because the number's position differs between the two languages. The backtick-wrapped count is passed in as the template field so the Slack code formatting is preserved.
  • Message wording is kept identical to the previous Japanese text, so existing Japanese notifications are unchanged.
  • Added table-driven tests covering all three attachment types in both en and ja.

s35560 and others added 2 commits August 20, 2026 12:00
The feature stale, experiment running and MAU count notifications were
sent in Japanese regardless of the recipient's language setting. Only
the domain event notification honored it.

Move the hardcoded Japanese strings into the locale bundle and pass the
existing localizer (built from Recipient.Language in notify()) down to
the three remaining attachment builders. This also covers the days-left
line of the experiment list, which was inlined in slack.go rather than
in message.go.

message.go is removed since localizedMessage() has no callers left.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ants

The Template suffix marks message IDs that must be resolved with
MustLocalizeWithTemplate. Every other templated constant in this file
follows it, so align the three subscription notification keys that take
a template field.

NotificationExperimentRunning keeps no suffix since it has no
placeholder and is resolved with MustLocalize.

Only the Go identifiers change; the message IDs and the localized data
are untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@kimurakazuhiro-c
kimurakazuhiro-c marked this pull request as ready for review August 20, 2026 04:25
@t-kikuc
t-kikuc requested a balanced review from Copilot August 20, 2026 04:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Localizes Slack subscription notifications using the shared locale system.

Changes:

  • Adds English and Japanese notification translations.
  • Passes recipient localizers into attachment builders.
  • Adds bilingual attachment tests and removes legacy localization code.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/subscription/sender/notifier/slack.go Localizes notification attachments.
pkg/subscription/sender/notifier/slack_test.go Tests English and Japanese rendering.
pkg/subscription/sender/notifier/message.go Removes legacy Japanese-only messages.
pkg/locale/localizer.go Defines notification locale keys.
pkg/locale/localizedata/ja.yaml Adds Japanese translations.
pkg/locale/localizedata/en.yaml Adds English translations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/locale/localizedata/en.yaml Outdated
…essage

Address review comments on PR #2778:
- "{{ .Field_1 }} days left" rendered "`1` days left" for an experiment
  with exactly one day remaining. Reword it as "Days left: {{ .Field_1 }}"
  so the English notification is grammatical for singular, plural, zero
  and negative values, and update the test expectation accordingly.

The Japanese message is already count-neutral and stays unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@t-kikuc t-kikuc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

@t-kikuc
t-kikuc merged commit e5c8e6c into main Aug 21, 2026
12 checks passed
@t-kikuc
t-kikuc deleted the chore/translate-slack-notification branch August 21, 2026 02:03
@t-kikuc

t-kikuc commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Closes #699

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.

3 participants