-
Notifications
You must be signed in to change notification settings - Fork 707
Fix RTL alignment for Persian/Arabic instruction sections #2509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughPull request adds internationalization support for right-to-left (RTL) languages. Introduces utility functions to detect language and RTL status, applies RTL CSS classes to HelpModal components, and restructures the attack ratio display in ControlPanel to support flexible alignment. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks✅ Passed checks (3 passed)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/client/HelpModal.ts (2)
45-49: Consider using Tailwind's text-right directly.The inline
.rtl-alignstyle appliestext-align: right, but you're already using Tailwind'stext-rightclass for tables. You could replace this custom CSS with Tailwind'stext-rightclass on line 55 instead.Apply this diff to use Tailwind exclusively:
- <style> - .rtl-align { - text-align: right; - } - </style> <o-modal id="helpModal" title="Instructions" translationKey="main.instructions" > - <div class="${isRtl ? "rtl-align" : ""}"> + <div class="${isRtl ? "text-right" : ""}">
55-67: Add dir="rtl" attribute for complete RTL support.While text alignment is handled via CSS classes, the
dir="rtl"attribute is important for proper bidirectional text rendering and affects element flow, margin/padding direction, and other browser behaviors beyond text alignment.Apply this diff to add proper direction attribute:
- <div class="${isRtl ? "rtl-align" : ""}"> + <div class="${isRtl ? "rtl-align" : ""}" dir="${isRtl ? "rtl" : "ltr"}">
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (3)
src/client/HelpModal.ts(3 hunks)src/client/Utils.ts(1 hunks)src/client/graphics/layers/ControlPanel.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: andrewNiziolek
Repo: openfrontio/OpenFrontIO PR: 1007
File: resources/lang/de.json:115-115
Timestamp: 2025-06-02T14:27:37.609Z
Learning: For OpenFrontIO project: When localization keys are renamed in language JSON files, the maintainers separate technical changes from translation content updates. They wait for community translators to update the actual translation values rather than attempting to translate in the same PR. This allows technical changes to proceed while ensuring accurate translations from native speakers.
Learnt from: TheGiraffe3
Repo: openfrontio/OpenFrontIO PR: 884
File: resources/lang/en.json:456-461
Timestamp: 2025-08-16T10:52:08.292Z
Learning: In OpenFrontIO, translation files in resources/lang/*.json (except en.json) should not be updated in regular PRs. Only dedicated translation PRs titled "mls" and made by Aotumori should update non-English locale files. Regular PRs should only update en.json when adding or modifying translation keys.
📚 Learning: 2025-07-23T12:36:35.354Z
Learnt from: Aotumuri
Repo: openfrontio/OpenFrontIO PR: 1534
File: src/client/LangSelector.ts:97-106
Timestamp: 2025-07-23T12:36:35.354Z
Learning: In OpenFrontIO's LangSelector.ts, the getClosestSupportedLang method always joins language code parts with underscores ("_") because all keys in the languageMap use underscore format (e.g., pt_BR, sv_SE, zh_CN). This normalization ensures consistency regardless of whether the input language code uses hyphens or underscores as delimiters.
Applied to files:
src/client/Utils.ts
🧬 Code graph analysis (2)
src/client/HelpModal.ts (2)
src/client/Utils.ts (2)
isRtlLanguage(164-167)translateText(92-147)src/client/LangSelector.ts (1)
translateText(258-278)
src/client/graphics/layers/ControlPanel.ts (1)
src/client/Utils.ts (2)
translateText(92-147)renderTroops(15-17)
🔇 Additional comments (6)
src/client/graphics/layers/ControlPanel.ts (1)
193-208: LGTM! Proper handling of numbers in RTL contexts.The use of
dir="ltr"withunicode-bidi: isolateensures numbers and percentage symbols display correctly in RTL languages. This follows web standards for mixed-direction content.src/client/HelpModal.ts (3)
3-8: LGTM! Clean import structure.
40-42: LGTM! Clear RTL detection logic.
460-460: LGTM! Consistent alignment across table bodies.src/client/Utils.ts (2)
149-157: LGTM! Clean utility following existing patterns.The function correctly queries the DOM for the language selector and uses optional chaining for safe access. Returning
nullwhen unavailable is clear and idiomatic.
159-167: LGTM! Comprehensive RTL detection.The function correctly identifies the three main RTL languages (Arabic, Farsi, Hebrew) and uses
.startsWith()to handle language variants with either hyphen or underscore delimiters. The implementation is clean and well-documented.




Description:
This PR fixes RTL alignment issues in Persian and Arabic UI sections.
Previously, some instruction and help texts were left-aligned when FA/AR was active.
The layout has now been updated to correctly apply RTL direction and right alignment.
Changes included:
Testing:
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
nobodyiran