Repository navigation
translate: split multi-word Persian names by character so the output compiles - #3683
Conversation
TranslateIdentifierFaToEn and the transliteration table walked the name one byte at a time, so the three byte ZWNJ never matched and no Persian letter was ever transliterated. A name with a ZWNJ at its declaration and a space at the call came out as two different names, count_رقمها and count_رقم_ها, and the translated file did not compile. Both sites now give the same Latin name.
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
salam translate enwrote a multi-word Persian name differently where it is declared and where it is called, so its own output did not compile.TranslateIdentifierFaToEnandtranslit_fa_to_enwalked the name one byte at a time. The ZWNJ is three bytes, so it never matched the separator test, and every comparison with a Persian letter failed, so nothing was ever transliterated.تابع شمار رقمهاwith a callشمار رقم ها(...)came out ascount_رقمهاandcount_رقم_ها(E234 and E012). Both functions now walk characters (CharCountandCharAtIndex) and both sites givecount_rghm_ha.tests/fa/translate/multiword_zwnj_call: a ZWNJ at the declaration and a space at the call, translated to English, built and run.tests/en/check/fix/bidi_after_backslash.fixedstill had lowercase.len()after the PascalCase rename.Checked on a build of this branch: the translated blog example from post 03 now checks clean,
match21 of 21 andtypes33 of 33,libandnewpass, andcheckis 30 of 32.Not fixed, and not caused by this change:
check/{en,fa}/prelude_namefail on a compiler without LLVM.std/threadimportscollectionssince Fix release seed selection and thread imports #3414, so the guard that lets a user file namedcollections.salamthrough no longer applies on the C path, and on that path the two modules really do collide in the generated C. The release build takes the LLVM path, where the check never runs. I tried makingcheckaccept it and dropped that, becausecheckwould then disagree withbuild, which is what salam check: fail when errors are printed, match what build reports #2685 exists to prevent.translateis 12 of 34 here. The failures are several separate problems in the translator: it does not map comparison operators to the Persian words (and back), some translated names collide with reserved words, a few stored page outputs are stale, and one test hits an unused variable. That needs its own change.Summary by CodeRabbit