Skip to content

translate: comparison words, PascalCase methods, keyword-safe names - #3690

Merged
BaseMax merged 6 commits into
mainfrom
fix/translate-operators
Nov 19, 2026
Merged

BaseMax merged 6 commits into
mainfrom
fix/translate-operators

Conversation

@BaseMax

@BaseMax BaseMax commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

More of the translator that #3352 left behind, taking the translate section from 12 of 34 on main to 24 of 35 on a build of this branch.

  • Comparison operators: translating to Persian turns ==, !=, <= and >= into the Persian words wherever they appear (they cannot be generics), including rule conditions and page conditions that the parser does not report as binary expressions. < and > still use the parsed-expression gaps, because they can be generics.
  • Methods: a call written as .Lower() or .StartsWith() is looked up under its snake_case key, so it gets its Persian name instead of a transliteration.
  • Names: the type, method and plain identifier paths now share tr_safe_name, which appends _ to a name that is a keyword in the target language and joins the parts of a multi-word name with a ZWNJ when one part is a keyword (this also addresses the CodeRabbit comment on translate: keep leading underscores, avoid reserved names, refresh three outputs #3686, where type references skipped the check).
  • layout_runtime_safe_types outputs (en and fa) regenerated; the printed values and the markup around the style block match the old files.

Still failing in translate, each needing its own change: names declared inside extern: and export: blocks are translated (2 tests), snake_case aliases and methods called on a call result such as .with_code() (2), page component and attribute names and enum values such as checkbox (4), value lists and Persian digits in page lines (2), and a multi-word name made of contextual keywords such as قاعده کل نیازمند (1).

Summary by CodeRabbit

  • Bug Fixes
    • Improved translation of Persian identifiers containing multiple words or keyword names.
    • Method translation can now fall back to snake-case names for Persian targets.
    • Corrected Persian comparison-operator translation, including handling comparisons within generic angles.

… a name

A leading underscore is what silences the unused variable error, and the translator dropped it. A translated name that is a keyword in the target language, for example the one letter v becoming و, now gets a trailing underscore.
Pages now carry the standard style block; the markup around it is unchanged.
Translating to Persian now turns == != <= >= into the Persian words wherever they appear, since they can never be generics, and < and > as before where the parser sees a comparison. A method written in PascalCase (.Lower) is looked up under its snake_case table key, so it gets its Persian name. Type, method and plain identifiers share one helper that appends an underscore to a name that is a keyword, and joins the parts of a multi-word name with a ZWNJ when one part is a keyword.
The style block is new; the printed values and the markup around it match.
# Conflicts:
#	compiler/cli/cli_translate.salam
@BaseMax
BaseMax requested a review from a team as a code owner November 19, 2026 21:17
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 31bc08ee-d0dc-4e9b-81c1-a56a78e801c7
Commits

Reviewing files that changed from the base of the PR and between 07af763 and 974248b.

Files ignored due to path filters: 2

  • tests/en/translate/layout_runtime_safe_types.out is excluded by !**/*.out
  • tests/fa/translate/layout_runtime_safe_types.out is excluded by !**/*.out
Files selected for processing: 1

  • compiler/cli/cli_translate.salam

No actionable comments were generated in the recent review.

Walkthrough

The CLI translation updates add safe-name handling for identifier and method fallbacks, including snake-case method lookup for Persian targets. Comparison-operator translation now uses source spelling, comparison gaps, and generic-angle depth when choosing Persian spellings.

Changes: Identifier translation

Layer / File(s) Summary
Safe identifier and method names
compiler/cli/cli_translate.salam
Identifier fallback joins Persian multiword translations with zero-width non-joiners when needed and appends _ when the result is a keyword. Type and method fallbacks use safe-name handling. Persian method translation also retries lookup with a snake-case name.

Comparison operators

Layer / File(s) Summary
Persian comparison spellings
compiler/cli/cli_translate.salam
English targets use the source symbol. Persian targets use Persian spellings when the source spelling differs, the operator falls in a comparison gap, or the operator is ==, !=, <=, or >= outside generic-angle brackets.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Possibly related PRs

  • SalamLang/Salam#3686: Updates the same identifier-translation path and applies keyword-safe naming to translated identifiers.

Suggested reviewers: bdadmehr0, erfangnu

Merge Risk: Minimal · previous review 07af7

The change adds Persian comparison words, PascalCase method lookup, and keyword-safe names to the translator. No concrete defect was established, so the merge risk is minimal. The author-disclosed remaining translate test failures are known limitations.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names three changes in the translator: comparison words, PascalCase method lookup, and keyword-safe names. The raw summary and objectives confirm each one. The title is specific to the chang…
Description check Passed The description follows the template's main idea. It explains the changes (comparison operators, method lookup, shared tr_safe_name) and gives test-result context (12 of 34 to 24 of 35). It lists rema…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names three changes in the translator: comparison words, PascalCase method lookup, and keyword-safe names. The raw summary and objectives confirm each one. The title is specific to the change and does not use vague terms. It is a long, comma-separated list, so it is slightly less concise than ideal, but it describes the main change accurately.

Full details: Description check

Explanation

The description follows the template's main idea. It explains the changes (comparison operators, method lookup, shared tr_safe_name) and gives test-result context (12 of 34 to 24 of 35). It lists remaining failures. It does not include the template's Related Issue section, a 'How Was This Tested' section with commands, or the checklist. It does reference #3352 and #3686, but without an explicit Closes/Related Issue line. The required test information is only partly given.

Resolution

Optional improvements: add an explicit Related Issue line (for example, 'Closes #...' or a reference to #3686 if it is the tracked issue). Add the test commands used to produce the 24 of 35 result, for example the salam command that runs the translate tests. Complete the checklist items that apply.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cdea50b0-7b23-4a9e-943c-47f4006fbffa
Commits

Reviewing files that changed from the base of the PR and between f2d13af and 07af763.

Files ignored due to path filters: 2

  • tests/en/translate/layout_runtime_safe_types.out is excluded by !**/*.out
  • tests/fa/translate/layout_runtime_safe_types.out is excluded by !**/*.out
Files selected for processing: 1

  • compiler/cli/cli_translate.salam

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor
sha=974248b08736110a4ea8181be57537442a2ed8ba

🤖 Salam AI review

Verdict: ✅ Good to merge

commit 974248b · 3 files · +146 −11 · model salam

Summary

This pull request improves the Salam translator by making identifier, type, and method name translation keyword-safe, adding PascalCase-to-snake_case method lookup for Persian output, and emitting Persian word forms for non-generic comparison operators such as ==, !=, <=, and >=. It also regenerates the English and Persian layout_runtime_safe_types translate outputs to include the current runtime style block. The visible changes align with the stated goals, though several translation cases remain documented as unfixed.

What changed

  • compiler/cli/cli_translate.salam: adds tr_safe_name to centralize translated-name handling, appending _ when a translated name is a reserved word and joining multi-word Persian translations with ZWNJ when any part is a keyword. tr_type_word, tr_method_word, and plain identifier emission now use it. A new tr_snake helper and a Persian fallback in tr_method_word let PascalCase methods resolve through snake_case mappings. Comparison handling now emits Persian spellings for ==, !=, <=, and >= outside generic-angle contexts, including gap/layout cases, while < and > keep the existing generic-aware behavior.
  • tests/en/translate/layout_runtime_safe_types.out and tests/fa/translate/layout_runtime_safe_types.out: regenerated to include the current runtime <style> content in the HTML head while keeping the previously visible page content.

Review

  • No concrete defects were identified in compiler/cli/cli_translate.salam from the provided diff. The added helpers and operator condition are consistent with the described fixes, and allocated split parts in tr_safe_name are freed on the handled path.

Tests

  • The diff updates two translate golden outputs, but it does not show additional input/expectation changes for the specific comparison, PascalCase method, or keyword-safe naming cases described, so the reported increase in passing translate cases cannot be confirmed from this diff alone.

Risks

  • The PR description notes remaining gaps: translated names in extern:/export: blocks, snake_case aliases and methods on call results, page component/attribute/enum translation, page value lists/Persian digits, and some multi-word contextual keyword names. The .out diffs were truncated in the review input, so the full regenerated style blocks and file tails were not visible.

⚠️ This review was written automatically by an AI and may contain mistakes. It is a helper for maintainers, not a replacement for a human review: check the code yourself before merging.

@BaseMax
BaseMax merged commit ce92ace into main Nov 19, 2026
14 checks passed
@BaseMax
BaseMax deleted the fix/translate-operators branch November 19, 2026 21:31
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.

1 participant