Skip to content

Issue712#770

Open
Matobi98 wants to merge 4 commits intolnp2pBot:mainfrom
Matobi98:issue712
Open

Issue712#770
Matobi98 wants to merge 4 commits intolnp2pBot:mainfrom
Matobi98:issue712

Conversation

@Matobi98
Copy link
Contributor

@Matobi98 Matobi98 commented Mar 24, 2026

Improve i18n flexibility for showusername order sentences

Problem

When a user sets /showusername yes and creates an order, the bot constructs a sentence using several isolated one-word strings from locales/en.yaml (lines 442–456):

selling: Selling
buying: Buying
is: is
sats: sats

This produces sentences like:

@username is Buying sats
@username is Selling sats

This approach assumes English word order, which breaks natural phrasing in many other languages. Translators are forced to work around a fixed sentence structure they have no control over.

A concrete example is Persian (Farsi), an RTL language. Telegram determines text direction based on the first character of each line. Since @username always comes first and @ is an LTR character, the entire line is rendered LTR — making Persian text appear incorrectly. A common workaround is prepending a native word (e.g. "کاربر" meaning "User") to trigger RTL rendering, but the current string structure makes this impossible.

Solution

Replace the four isolated strings with two complete, context-aware strings:

showusername_buy: '@${username} is buying sats'
showusername_sell: '@${username} is selling sats'

This gives translators full control over word order, sentence structure, and the ability to add language-specific words where needed — without changing the meaning for English speakers.

Changes

  • Removed selling, buying, is, and sats entries used for order sentence construction from locales/en.yaml
  • Added showusername_buy and showusername_sell with interpolated ${username}
  • Updated all locale files and the corresponding bot logic to use the new strings

Summary by CodeRabbit

  • New Features
    • Order descriptions now use more specific "sats" messaging and refined title lines for buy/sell orders.
    • When enabled in profile settings, order titles include the trader's username for clearer context.
    • Localized strings updated across languages to add sats-specific labels and username-aware templates.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 24, 2026

Walkthrough

Refactors order description title generation by introducing getOrderTitleMessage(user, type, i18n) and updates many locale files to replace generic selling/buying keys with sats-specific and username-aware variants.

Changes

Cohort / File(s) Summary
Order Description Logic
bot/ordersActions.ts
Extracted inline title construction into getOrderTitleMessage; buildDescription now uses that helper and sets the first description line from its result.
Internationalization Keys
locales/{de,en,es,fa,fr,it,ko,pt,ru,uk}.yaml
Replaced generic selling/buying keys with selling_sats/buying_sats and added username-aware keys showusername_selling_sats/showusername_buying_sats across the listed locale files.
Package File
package.json
Removed trailing newline at EOF (non-functional formatting change).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • grunch
  • Luquitasjeffrey

Poem

🐇 I hopped in code, a tiny bit,

I stitched the title—now it fits.
Selling sats or buying too,
@username sings in languages new.
Hops and bytes — a joyful fix!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The PR title 'Issue712' is vague and generic, using only an issue number without describing the actual change made in the pull request. Use a descriptive title that summarizes the main change, such as 'Refactor order description to use locale-specific sentence templates' or 'Replace fragmented locale keys with complete sentence templates for showusername feature'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
bot/ordersActions.ts (1)

244-250: ⚠️ Potential issue | 🟠 Major

Remove unused amountText to unblock lint.

amountText is assigned but never read (Line 244 / Line 247), and CI is failing on typescript-eslint/no-unused-vars.

🧹 Suggested fix
-    let amountText = `${numberFormat(fiatCode, amount)} `;
     let tasaText = '';
     if (priceFromAPI) {
-      amountText = '';
       tasaText =
         i18n.t('rate') + `: ${process.env.FIAT_RATE_NAME} ${priceMarginText}\n`;
     } else {

As per coding guidelines, "Follow ESLint Standard plus TypeScript rules and address warnings instead of disabling them".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bot/ordersActions.ts` around lines 244 - 250, The variable amountText is
assigned but never used in the block guarded by priceFromAPI causing a lint
error; remove the unused assignment and any redundant initialization of
amountText and instead only set tasaText when priceFromAPI is truthy (keep the
existing use of tasaText, priceFromAPI, numberFormat, fiatCode and amount
elsewhere intact), or collapse the conditional so amountText is not declared at
all in this scope—ensure references to amountText elsewhere are preserved or
replaced if they relied on this value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@locales/fr.yaml`:
- Line 441: The French translation key showusername_selling_sats uses the
incorrect verb form "vent"; update its value to use the singular conjugation
"vend" so the line reads showusername_selling_sats: "@${username} vend des sats"
to match the singular subject interpolation @${username}.

---

Outside diff comments:
In `@bot/ordersActions.ts`:
- Around line 244-250: The variable amountText is assigned but never used in the
block guarded by priceFromAPI causing a lint error; remove the unused assignment
and any redundant initialization of amountText and instead only set tasaText
when priceFromAPI is truthy (keep the existing use of tasaText, priceFromAPI,
numberFormat, fiatCode and amount elsewhere intact), or collapse the conditional
so amountText is not declared at all in this scope—ensure references to
amountText elsewhere are preserved or replaced if they relied on this value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d052ce83-ced9-4825-b670-f78bd928e73d

📥 Commits

Reviewing files that changed from the base of the PR and between 4a8ff74 and b7cb71e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 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
  • package.json

buying_sats: Achat de sats
receive_payment: Réception du paiement
showusername_buying_sats: "@${username} achète des sats"
showusername_selling_sats: "@${username} vent des sats"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix French conjugation in username sell sentence.
Line 441 currently says vent; it should be vend for singular subject (@${username}).

✏️ Proposed fix
-showusername_selling_sats: "@${username} vent des sats"
+showusername_selling_sats: "@${username} vend des sats"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
showusername_selling_sats: "@${username} vent des sats"
showusername_selling_sats: "@${username} vend des sats"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@locales/fr.yaml` at line 441, The French translation key
showusername_selling_sats uses the incorrect verb form "vent"; update its value
to use the singular conjugation "vend" so the line reads
showusername_selling_sats: "@${username} vend des sats" to match the singular
subject interpolation @${username}.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
bot/ordersActions.ts (1)

263-296: ⚠️ Potential issue | 🟡 Minor

Fix Prettier formatting before merging.

The CI pipeline reports formatting violations on these lines. As per coding guidelines, run Prettier before committing.

npm run format
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bot/ordersActions.ts` around lines 263 - 296, The file has Prettier
formatting issues; run the formatter and fix whitespace/line breaks around the
description assembly in the ordersActions.ts function (the multi-line
description construction and related template strings) and ensure
getOrderTitleMessage remains unchanged in behavior; run "npm run format" and
commit the formatted changes so the CI formatting checks pass.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@bot/ordersActions.ts`:
- Around line 263-296: The file has Prettier formatting issues; run the
formatter and fix whitespace/line breaks around the description assembly in the
ordersActions.ts function (the multi-line description construction and related
template strings) and ensure getOrderTitleMessage remains unchanged in behavior;
run "npm run format" and commit the formatted changes so the CI formatting
checks pass.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 891f57e4-e6b2-4c99-b085-07f0c8c8ab8a

📥 Commits

Reviewing files that changed from the base of the PR and between b7cb71e and 4a3aa7e.

📒 Files selected for processing (1)
  • bot/ordersActions.ts

@knocte
Copy link
Collaborator

knocte commented Mar 24, 2026

utACK, pls fix CI

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