Transliterate Pali and Tibetan texts in Events - #798
Conversation
- Introduced sample text files for Tibetan (Unicode and Wylie) transliteration. - Implemented PaliScriptConverter for detecting and converting Pali scripts. - Added tests for PaliScriptConverter to ensure correct script detection and conversion. - Created ReaderScriptPreferenceProvider to manage user script preferences with local storage. - Developed TibetanPhonetics for phonetic transcription of Tibetan names and texts. - Implemented TibetanScriptConverter for handling Tibetan script conversion and phonetic output. - Added tests for TibetanScriptConverter to validate script detection and conversion functionality. - Enhanced TransliterationService to support multiple scripts and caching for performance. - Included tests for TransliterationService to verify conversion and caching behavior.
…into feat/reader-transliteration
- Call the Roman row "Roman", its own name like every other script, and drop the reader_roman_transliteration l10n key from all six locales - Map the Thai private-use glyphs the Pali package emits back to ญ and ฐ - Close Myanmar syllables with asat and drop dangling Khmer coeng, so Tibetan phonetics such as "chak" render without dotted circles - Give ཤ and ཞ each script's ś letter instead of an s + h cluster - Drop Brahmi from the script list: no phone ships a font for it - Put the reader's gap between verses (28 px) instead of between the original and its translation (6 px)
…into feat/reader-transliteration
…sts for punctuation and line breaks
|
| final secondaryVersionId = dualSettings.secondary.versionId; | ||
| final secondaryActive = | ||
| dualSettings.secondaryEnabled && secondaryVersionId != null; | ||
| // "Translation only": the original can hide behind an active translation, | ||
| // never on its own. | ||
| final showOriginal = dualSettings.originalVisible || !secondaryActive; |
There was a problem hiding this comment.
In translation-only mode, a selected secondary version is treated as available before its content has loaded successfully. If the secondary request fails or a segment has no aligned translation, the original remains hidden and the reader displays only loading text or em dashes. Keep the original visible until usable secondary content exists, or restore it when secondary content fails or is missing.
Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/features/reader/presentation/widgets/reader_content/reader_content_part.dart
Line: 701-706
Comment:
**Original text can disappear**
In translation-only mode, a selected secondary version is treated as available before its content has loaded successfully. If the secondary request fails or a segment has no aligned translation, the original remains hidden and the reader displays only loading text or em dashes. Keep the original visible until usable secondary content exists, or restore it when secondary content fails or is missing.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.…user changes and improve layer handling
…anslation line and update copy action logic; add tests for translation retrieval scenarios.
Detect the original's script from the verses, not the title. Catalogue titles are romanised as a matter of course, so a Tibetan text called "Derge Kangyur" was read as Roman: the Original field claimed Roman while the body stayed in Uchen, and the real Roman row - THL phonetics, the feature worth having - was filtered out as "the script already on screen". The reader now hands the sheet a sample of the loaded segments, and detectScript lets a Latin script win only when no other script's letters appear, so a siglum or a loanword inside a verse cannot outvote it. A pick naming the source script now ticks the "as written" row instead of leaving the list with nothing ticked. Leave footnotes as the editor wrote them. convertHtml transliterated every text node, so "So PTS; see Burmese ed. page 12." came back as Sinhala letters. It now tracks element nesting and skips anything classed footnote or footnote-marker. Convert only the line breaks the converter introduced. The decision keyed off the source chunk, so one raw newline - HTML whitespace, not a break - suppressed every <br> the mark style produced in it, and a pretty-printed document ran its verses together. Each source line is now converted on its own and rejoined as it came. Accept a hex escape in either case in EwtsConverter, as BDRC's Java converter and pyewts do. Sloppy normalisation lower-cases a stray b but not an F, so ་ was rejected as invalid and the character dropped.
| } else if (!closing && | ||
| !raw.endsWith('/>') && | ||
| _footnoteClass.hasMatch(raw)) { | ||
| skippedTag = name; | ||
| skipDepth = 1; |
There was a problem hiding this comment.
A valid HTML void element such as <img class="footnote-marker"> does not need a /> suffix. This code enters footnote-skip mode for that tag, but can leave the mode only after a matching </img>, which a void element never has. As a result, all following verse text in the segment is left untranslated. Detect HTML void elements independently of self-closing syntax before starting a skipped region.
Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/features/reader/domain/transliteration/transliteration_service.dart
Line: 100-104
Comment:
**Void Tag Swallows Verse**
A valid HTML void element such as `<img class="footnote-marker">` does not need a `/>` suffix. This code enters footnote-skip mode for that tag, but can leave the mode only after a matching `</img>`, which a void element never has. As a result, all following verse text in the segment is left untranslated. Detect HTML void elements independently of self-closing syntax before starting a skipped region.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Readers can now see a text's original verses in another script. Everything runs on the phone; the backend is untouched.
What's in it
pali_script_convertor: Devanagari, Sinhala, Thai, Myanmar, Khmer, Bengali, Gurmukhi, Gujarati, Telugu, Kannada, Malayalam, Tibetan and Cyrillic, plus Roman. A post-pass repairs the package's Thai private-use glyphs and Myanmar/Khmer dangling stack marks.TransliterationService.standard().Not in it