Skip to content

refactor: split order title i18n keys into no-amount / with-amount variants#859

Open
grunch wants to merge 1 commit into
mainfrom
refactor/order-title-i18n-amount
Open

refactor: split order title i18n keys into no-amount / with-amount variants#859
grunch wants to merge 1 commit into
mainfrom
refactor/order-title-i18n-amount

Conversation

@grunch

@grunch grunch commented Jul 2, 2026

Copy link
Copy Markdown
Member

Closes #854

Problem

After #852 the order title keys interpolate ${amount} with no space in the template ('Selling ${amount}sats') because the separating space lives inside the interpolated variable as a trailing-space hack. That's invisible to translators: adding the "missing" space in the YAML produces a double space, and languages where the amount can't sit adjacent to the noun can't reorder safely.

Changes

Locales (all 10): each title key is split into two explicit variants, with the space visible in the template:

selling_sats: Selling sats                              # market/range orders
selling_sats_with_amount: 'Selling ${amount} sats'      # fixed orders

Same for buying_sats and both showusername_* keys. The no-amount variants restore the pre-#770 wording verbatim (e.g. French recovers "achète des sats", which the single-key version had to drop). The with-amount variants keep each locale's current wording, just with an explicit space — native-speaker review welcome.

getOrderTitleMessage: selects the key variant instead of building an empty-or-trailing-space string; takes an options object (OrderTitleArguments) instead of 6 positional params; the comment now matches the actual guard (priceFromAPI, not amount === 0).

Spec: tests/bot/ordersActions.spec.ts updated to the new signature with identical expected strings — the regression test from #852 passing unchanged is the proof that rendered output is preserved.

Notes

Test plan

Summary by CodeRabbit

  • New Features

    • Improved order and trade labels across supported languages, with clearer “buy/sell sats” text.
    • Added separate message variants for labels with and without amounts.
  • Bug Fixes

    • Fixed spacing in satoshi amounts so values now display more naturally, such as 10 sats instead of 10sats.
    • Fixed order titles so amount details are shown only where appropriate, avoiding extra or missing formatting.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: abe8075e-ab07-4f90-83cb-a6dfc29fb2e1

📥 Commits

Reviewing files that changed from the base of the PR and between b80cb35 and 532622e.

📒 Files selected for processing (12)
  • bot/ordersActions.ts
  • locales/de.yaml
  • locales/en.yaml
  • locales/es.yaml
  • locales/fa.yaml
  • locales/fr.yaml
  • locales/it.yaml
  • locales/ko.yaml
  • locales/pt.yaml
  • locales/ru.yaml
  • locales/uk.yaml
  • tests/bot/ordersActions.spec.ts
 _______________________________________
< 💖 Git blame less, Git forgive more 🤝. >
 ---------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/order-title-i18n-amount

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@grunch grunch force-pushed the refactor/order-title-i18n-amount branch from c664a0d to 532622e Compare July 2, 2026 19:21

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
tests/bot/ordersActions.spec.ts (1)

59-93: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Test coverage gap: two of the eight title branches are untested.

Across both describe blocks, showusername_buying_sats_with_amount (username + buy + fixed) and showusername_selling_sats (username + sell + market/range) are never exercised. Consider adding one test case per block for symmetry with the existing username-based assertions.

✅ Suggested additional test cases
     it('shows the username and the sats amount when the user shows their name', () => {
       const title = getOrderTitleMessage(i18nCtx, {
         user: publicUser,
         type: 'sell',
         amount: 100,
         fiatCode: 'USD',
         priceFromAPI: false,
       });

       expect(title).to.equal('`@alice` is selling 100 sats');
     });
+
+    it('shows the username and the sats amount when buying', () => {
+      const title = getOrderTitleMessage(i18nCtx, {
+        user: publicUser,
+        type: 'buy',
+        amount: 100,
+        fiatCode: 'USD',
+        priceFromAPI: false,
+      });
+
+      expect(title).to.equal('`@alice` is buying 100 sats');
+    });
   });
     it('shows the username but omits the amount when the user shows their name', () => {
       const title = getOrderTitleMessage(i18nCtx, {
         user: publicUser,
         type: 'buy',
         amount: 0,
         fiatCode: 'USD',
         priceFromAPI: true,
       });
+
+      expect(title).to.equal('`@alice` is buying sats');
+    });
+
+    it('shows the username but omits the amount when selling', () => {
+      const title = getOrderTitleMessage(i18nCtx, {
+        user: publicUser,
+        type: 'sell',
+        amount: 0,
+        fiatCode: 'USD',
+        priceFromAPI: true,
+      });
+
+      expect(title).to.equal('`@alice` is selling sats');
     });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/bot/ordersActions.spec.ts` around lines 59 - 93, Add the missing title
coverage in getOrderTitleMessage by creating one username-based test for the
fixed-price buy branch and one for the market/range sell branch, alongside the
existing anonymousUser/publicUser cases in tests/bot/ordersActions.spec.ts. Use
the same describe blocks and verify the exact formatted title for publicUser so
the showusername_buying_sats_with_amount and showusername_selling_sats paths are
exercised.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/bot/ordersActions.spec.ts`:
- Around line 59-93: Add the missing title coverage in getOrderTitleMessage by
creating one username-based test for the fixed-price buy branch and one for the
market/range sell branch, alongside the existing anonymousUser/publicUser cases
in tests/bot/ordersActions.spec.ts. Use the same describe blocks and verify the
exact formatted title for publicUser so the showusername_buying_sats_with_amount
and showusername_selling_sats paths are exercised.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: abe8075e-ab07-4f90-83cb-a6dfc29fb2e1

📥 Commits

Reviewing files that changed from the base of the PR and between b80cb35 and 532622e.

📒 Files selected for processing (12)
  • bot/ordersActions.ts
  • locales/de.yaml
  • locales/en.yaml
  • locales/es.yaml
  • locales/fa.yaml
  • locales/fr.yaml
  • locales/it.yaml
  • locales/ko.yaml
  • locales/pt.yaml
  • locales/ru.yaml
  • locales/uk.yaml
  • tests/bot/ordersActions.spec.ts

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.

Fragile i18n pattern in order title strings (${amount} with embedded trailing space)

1 participant