Skip to content

Improve i18n flexibility for showusername order sentences Issue712 - #770

Merged
grunch merged 7 commits into
lnp2pBot:mainfrom
Matobi98:issue712
Apr 10, 2026
Merged

Improve i18n flexibility for showusername order sentences Issue712#770
grunch merged 7 commits into
lnp2pBot:mainfrom
Matobi98:issue712

Conversation

@Matobi98

@Matobi98 Matobi98 commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

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 locale files:

  • selling: Selling
  • buying: Buying

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 isolated selling and buying strings with complete, context-aware strings:

showusername_selling_sats: '@${username} is selling sats'
showusername_buying_sats: '@${username} is buying sats'

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Order descriptions now clearly indicate sats trading context with optional counterparty username display for enhanced transaction clarity.

* **Localization**
  * Updated translation strings across all supported languages including English, German, Spanish, French, Italian, Korean, Portuguese, Russian, Ukrainian, and Persian.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@coderabbitai

coderabbitai Bot commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 10f50c78-413f-48a0-894b-f9af9da2ebd3

📥 Commits

Reviewing files that changed from the base of the PR and between 83ab215 and c0330b8.

📒 Files selected for processing (1)
  • locales/fr.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • locales/fr.yaml

Walkthrough

This PR refactors order title message generation by introducing a dedicated helper function getOrderTitleMessage() and updates all supported locale files to replace generic "selling"/"buying" keys with sats-specific variants and username-aware templates.

Changes

Cohort / File(s) Summary
TypeScript Logic
bot/ordersActions.ts
Extracted order title composition into dedicated getOrderTitleMessage() helper that selects locale keys based on order type and username visibility setting. Simplified buildDescription to derive the complete first line via this helper instead of concatenating separate locale fragments.
Locale Files - Sats & Username Keys
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
Replaced generic selling/buying keys with sats-specific selling_sats/buying_sats variants across all languages. Added new username-templated keys showusername_selling_sats and showusername_buying_sats to each locale file to support displaying counterparty handles in order descriptions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • grunch
  • Luquitasjeffrey

Poem

🐰 Hops of joy through locale files so bright,
From fragmented words to sats unified!
Username templates bloom in each tongue's delight,
One helper function, refactored with pride,
Messages flow now—complete, pure, and right!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: refactoring i18n to improve flexibility for showusername order sentences by replacing isolated word fragments with complete, interpolated locale strings.
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.

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

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

Comment thread locales/fr.yaml Outdated

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

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

knocte commented Mar 24, 2026

Copy link
Copy Markdown
Collaborator

utACK, pls fix CI

@Matobi98 Matobi98 changed the title Issue712 Improve i18n flexibility for showusername order sentences Issue712 Mar 28, 2026

@mostronatorcoder mostronatorcoder 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.

Code Review: PR #770

Estado general: Funcionalmente correcto.

🔴 Blocking

Typo en francés — → en .

🟡 Minor

  1. Keys huérfanas en todos los locale files.
  2. PR description no coincide con el diff real.

✅ Lo que está bien

  • correcta y clara
  • 4 casos bien cubiertos
  • Nuevas keys de locale en todos los idiomas
  • Enfoque de oración completa (resuelve Persian RTL)
  • PR mergeable, CI verde

Veredicto: Request Changes — typo → y limpiar keys huérfanas.

'vent' (wind) → 'vend' (sells) in locales/fr.yaml.
@Matobi98

Copy link
Copy Markdown
Contributor Author

French typo — Fixed: vent → vend in locales/fr.yaml.

PR description — Updated to reflect the actual diff: the key names are showusername_selling_sats /
showusername_buying_sats (not showusername_buy / showusername_sell), and clarified that is and sats were not removed.

Orphan keys — I checked and none of them were introduced by this PR. They are all pre-existing issues: disput_too_soon and
Wizard_community_duplicated_name in de.yaml, and error_parsing_invoice in ru.yaml and uk.yaml. I'll leave them for a
dedicated cleanup PR.

@Luquitasjeffrey Luquitasjeffrey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

tACK

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.

4 participants