Skip to content

feat: add multilingual mass unit aliases for all 7 app languages#108

Open
konard wants to merge 7 commits intomainfrom
issue-99-3002120d8025
Open

feat: add multilingual mass unit aliases for all 7 app languages#108
konard wants to merge 7 commits intomainfrom
issue-99-3002120d8025

Conversation

@konard
Copy link
Contributor

@konard konard commented Mar 22, 2026

Summary

Fixes #99

The calculator did not recognize non-Latin mass unit names like "кг" (Russian for "kg"). While currencies already had extensive multilingual support across all 7 app languages, mass units only had English aliases.

This PR adds:

  • Multilingual mass unit aliases in MassUnit::parse() for Russian (кг, г, мг, тонна, унция with all grammatical cases), Chinese (公斤, 千克, 克, 吨, 磅, 盎司, 毫克), Hindi (किलोग्राम, ग्राम, टन, किलो, औंस, मिलीग्राम), Arabic (كيلوغرام, غرام, طن, رطل, أونصة, كغ), German (Kilogramm, Gramm, Kilo, Unze, Tonnen), and French (kilogramme, gramme, milligramme, once)
  • Unicode combining mark support in the lexer so scripts like Devanagari (Hindi) and Arabic with diacritical marks are properly tokenized as identifiers
  • Bug fix for a pre-existing compilation error in number_grammar.rs where DurationUnit::parse returned the wrong type

Changes

File Change
src/types/unit.rs Added ~80 multilingual aliases to MassUnit::parse()
src/grammar/lexer.rs Added is_unicode_mark() for combining mark support in scan_identifier()
src/grammar/number_grammar.rs Fixed DurationUnit return type bug
tests/issue_99_multilingual_mass_tests.rs 53 new tests covering all 7 languages
changelog.d/ Added changelog fragment
Cargo.toml Version bump to 0.9.0

Test plan

  • All 53 new multilingual mass unit tests pass
  • All 600+ existing tests pass (0 regressions)
  • cargo fmt --check passes
  • cargo clippy --all-targets --all-features passes clean
  • File size check passes
  • The exact input from the issue (19 ton в кг) produces 19000 kg

🤖 Generated with Claude Code

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #99
@konard konard self-assigned this Mar 22, 2026
konard and others added 3 commits March 22, 2026 22:51
Add non-Latin mass unit aliases (кг, г, тонна, 千克, 公斤, किलोग्राम, كيلوغرام, etc.)
to MassUnit::parse() for Russian, Chinese, Hindi, Arabic, German, and French.

Also fix pre-existing compilation error in number_grammar.rs where DurationUnit
parse returned Unit instead of the expected (Unit, Vec<Unit>) tuple.

Fixes #99

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add Unicode combining mark support to lexer's scan_identifier() so that
  Devanagari (Hindi), Arabic diacritics, and other scripts with combining
  marks are properly tokenized as identifiers.

- Add case-insensitive fallback for mass unit parsing in source unit context
  (German nouns are capitalized: "Kilogramm", "Gramm", etc.)

- Add comprehensive test suite (53 tests) covering mass unit conversions
  in Russian, Chinese, Hindi, Arabic, German, and French.

Fixes #99

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@konard konard changed the title [WIP] Unrecognized input: 19 ton в кг feat: add multilingual mass unit aliases for all 7 app languages Mar 22, 2026
@konard konard marked this pull request as ready for review March 22, 2026 22:58
@konard
Copy link
Contributor Author

konard commented Mar 22, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $9.042228
  • Calculated by Anthropic: $6.013719 USD
  • Difference: $-3.028509 (-33.49%)

🤖 Models used:

  • Tool: Claude
  • Requested: opus
  • Main model: Claude Opus 4.6 (claude-opus-4-6)
  • Additional models:
    • Claude Haiku 4.5 (claude-haiku-4-5-20251001)

📎 Log file uploaded as Gist (2317KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Contributor Author

konard commented Mar 22, 2026

🔄 Auto-restart triggered (iteration 1)

Reason: CI failures detected

Starting new session to address the issues.


Auto-restart-until-mergeable mode is active. Will continue until PR becomes mergeable.

konard and others added 2 commits March 22, 2026 23:04
The CI/CD pipeline manages version bumps via changelog fragments.
The manual version change in Cargo.toml (0.8.2 → 0.9.0) was causing
the "Version Modification Check" CI step to fail.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@konard
Copy link
Contributor Author

konard commented Mar 22, 2026

🔄 Auto-restart-until-mergeable Log (iteration 1)

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $1.335183
  • Calculated by Anthropic: $0.735504 USD
  • Difference: $-0.599679 (-44.91%)

🤖 Models used:

  • Tool: Claude
  • Requested: opus
  • Model: Claude Opus 4.6 (claude-opus-4-6)

📎 Log file uploaded as Gist (2797KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Contributor Author

konard commented Mar 22, 2026

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

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.

Unrecognized input: 19 ton в кг

1 participant