Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(TextSegment): do not send primary / translation text to html… #2230

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions static/css/s2.css
Original file line number Diff line number Diff line change
Expand Up @@ -1525,10 +1525,8 @@ div.interfaceLinks-row a {
.readerPanel.english .contentText .he,
.readerPanel.hebrew .contentText .en,
.readerPanel.english .contentSpan.primary,
.readerPanel.english .connectionsPanel .contentSpan.primary,
.readerPanel.english .languageToggle .he,
.readerPanel.hebrew .contentSpan.translation,
.readerPanel.hebrew .connectionsPanel .contentSpan.translation,
.readerPanel.hebrew .languageToggle .en {
display: none;
}
Expand Down
19 changes: 12 additions & 7 deletions static/js/TextRange.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,10 @@ class TextSegment extends Component {
en = this.props.formatEnAsPoetry ? this.addPoetrySpans(en) : en
he = this.props.formatHeAsPoetry ? this.addPoetrySpans(he) : he

const hasOnlyRtl = (!this.props.en && this.props?.primaryDirection === 'rtl');
const hasOnlyLtr = !this.props.en && this.props?.primaryDirection === 'ltr';
const hasNoTranslation = !this.props.en;

const hasOnlyRtl = (hasNoTranslation && this.props?.primaryDirection === 'rtl');
const hasOnlyLtr = hasNoTranslation && this.props?.primaryDirection === 'ltr';
let sidebarRtl, sidebarLtr;
if (panelMode === 'Connections') {
const directionAttr = (language === 'hebrew') ? 'primaryDirection' : 'translationDirection';
Expand Down Expand Up @@ -625,14 +627,17 @@ class TextSegment extends Component {
</div>
) : null;

const primary = {

const shouldPrimaryShow = language !== 'english' || hasNoTranslation;
const primary = shouldPrimaryShow ? {
direction: this.props.primaryDirection,
text: he + " ",
};
const translation = {
} : {};
const shouldTranslationShow = language !== 'hebrew';
const translation = shouldTranslationShow ? {
direction: this.props.translationDirection,
text: en + " ",
};
} : {};

const classes=classNames({
segment: 1,
Expand All @@ -642,7 +647,7 @@ class TextSegment extends Component {
enOnly: enOnly,
showNamedEntityLinks: !!this.props.onNamedEntityClick,
});
if(!this.props.en && !this.props.he){
if(hasNoTranslation && !this.props.he){
return false;
}
return (
Expand Down
Loading