Enhance internationalization and UI components: Add new segment types… - #614
Conversation
… to en.json, improve layout spacing in RelatedTexts and TranslationView components, and update alignment logic in library services. Add tests for segment translations and related segments to ensure accurate data handling.
|
| segments: [], | ||
| segments: segments.map((segment, index) => ({ | ||
| id: segment.id, | ||
| content: contents[index], |
There was a problem hiding this comment.
The service now passes each related segment's structural type to the panel and adds localized labels, but both related-resource views still render only item.content. Nothing reads item.type or the new segment.type.* keys, so titles, front matter, back matter, and verses remain visually indistinguishable even though the new service behavior and tests say the panel labels them.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/services/library/segments.ts
Line: 236
Comment:
**Segment Types Stay Hidden**
The service now passes each related segment's structural type to the panel and adds localized labels, but both related-resource views still render only `item.content`. Nothing reads `item.type` or the new `segment.type.*` keys, so titles, front matter, back matter, and verses remain visually indistinguishable even though the new service behavior and tests say the panel labels them.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| const classifyText = (text: LibraryText | null | undefined): string => | ||
| text?.commentary_of ? COMMENTARY : TRANSLATION; |
There was a problem hiding this comment.
Missing Texts Become Translations
fetchTextSafe converts both missing metadata and transient metadata failures to null, but this classifier assigns every null value to the translation category. A stale related text_id or failed metadata request can therefore create and count a translation group with an empty title and null language, producing a blank translation entry instead of omitting or explicitly handling unavailable metadata.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/services/library/segments.ts
Line: 40-41
Comment:
**Missing Texts Become Translations**
`fetchTextSafe` converts both missing metadata and transient metadata failures to `null`, but this classifier assigns every null value to the translation category. A stale related `text_id` or failed metadata request can therefore create and count a translation group with an empty title and null language, producing a blank translation entry instead of omitting or explicitly handling unavailable metadata.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.…tionView: Update UI to display segment types for better clarity. Enhance tests to verify segment type rendering and handle cases with missing types.
| {commentary.title && ( | ||
| <h3 | ||
| className={` my-2 border-b-2 border-red-700 pb-3 text-lg font-semibold text-gray-800 ${getLanguageClass( | ||
| commentary.language, | ||
| )}`} | ||
| > | ||
| {commentary.title} | ||
| {commentary.segments?.length > 1 | ||
| ? ` (${commentary.segments.length})` | ||
| : ""} | ||
| </h3> | ||
| )} |
There was a problem hiding this comment.
When metadata is unavailable and the title is empty, this condition removes the whole heading, including the segment count, language styling, and only visible group identifier. The same pattern appears in RootText.tsx. If multiple untitled groups are shown, they become indistinguishable stacks with only generic “Open Text” actions, making it difficult to tell which text each segment belongs to.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/routes/chapterV2/utils/resources/components/related-texts/RelatedTexts.tsx
Line: 70-81
Comment:
**Untitled Groups Lose Identity**
When metadata is unavailable and the title is empty, this condition removes the whole heading, including the segment count, language styling, and only visible group identifier. The same pattern appears in `RootText.tsx`. If multiple untitled groups are shown, they become indistinguishable stacks with only generic “Open Text” actions, making it difficult to tell which text each segment belongs to.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…abel to en.json for better handling of missing titles in RelatedTexts and RootText components. Update TranslationView to display this label when titles are absent, and add tests to verify the correct rendering of the label in various scenarios.
|
❌ The last analysis has failed. |
… to en.json, improve layout spacing in RelatedTexts and TranslationView components, and update alignment logic in library services. Add tests for segment translations and related segments to ensure accurate data handling.