Skip to content

Update line break draft format wording #3273

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions src/RealtimeServer/scriptureforge/models/translate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export enum ParagraphBreakFormat {
MoveToEnd = 'move_to_end'
}

export enum QuoteFormat {
Automatic = 'automatic',
Straight = 'straight'
}

export interface BaseProject {
paratextId: string;
shortName: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
<app-draft-download-button [build]="entry" [flat]="true" />
@if (featureFlags.usfmFormat.enabled && isLatestBuild) {
<button mat-button class="format-usfm" [routerLink]="['format']">
<mat-icon>settings</mat-icon>
{{ t("format_draft") }}
<mat-icon>build</mat-icon> {{ t("format_draft") }}
</button>
}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,24 @@ <h1>{{ t("draft_format_options") }}</h1>
<div class="format-container">
<div class="format-options">
<form [formGroup]="usfmFormatForm" (change)="reloadText()">
<p>
{{ t("draft_format_description") }}
</p>
<p>{{ t("draft_format_description") }}</p>
<mat-card class="options">
<mat-card-header
><mat-card-title>{{ t("paragraph_break_title") }}</mat-card-title></mat-card-header
><mat-card-title>{{ t("line_breaks_title") }}</mat-card-title></mat-card-header
>
<mat-card-content class="format-options">
{{ t("paragraph_break_description") }}
<span>{{ t("line_breaks_description") }}</span>
<mat-radio-group formControlName="paragraphFormat">
<mat-radio-button [value]="paragraphBreakFormat.BestGuess">
{{ t("option_best_guess") }}
<span class="new">new</span>
<span class="new">{{ t("new") }}</span>
<span class="description">
{{ t("option_best_guess_description") }} Recommended for most projects.
{{ t("option_best_guess_description") }}
</span>
</mat-radio-button>
<mat-radio-button [value]="paragraphBreakFormat.Remove">
{{ t("option_remove") }}
<span class="new">new</span>
<span class="new">{{ t("new") }}</span>
<span class="description">
{{ t("option_remove_description") }}
</span>
Expand All @@ -43,14 +41,14 @@ <h1>{{ t("draft_format_options") }}</h1>
</mat-card-header>
<mat-card-content class="format-options">
Choose how quotes should appear in the draft.
<mat-radio-group>
<mat-radio-button value="best-guess">
Automatic quote style <span class="new">new</span>
<mat-radio-group formControlName="quoteFormat">
<mat-radio-button [value]="quoteStyleFormat.Automatic">
Automatic quote style <span class="new">{{ t("new") }}</span>
<span class="description">
Attempt to use the same quote style as the rest of the project. Recommended for most projects.
Use the same quote style as the rest of the project, if possible. Recommended for most projects.
</span>
</mat-radio-button>
<mat-radio-button value="remove">
<mat-radio-button [value]="quoteStyleFormat.Straight">
Straight quotes
<span class="description"> Use only straight quotes in the draft.</span>
</mat-radio-button>
Expand All @@ -64,6 +62,9 @@ <h1>{{ t("draft_format_options") }}</h1>
<mat-icon>check</mat-icon>
{{ t("save_changes") }}
</button>
<div class="progress" [ngClass]="{ saving: saving }">
<mat-spinner diameter="24"></mat-spinner>
</div>
</div>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,16 @@ form {

.actions {
display: flex;
justify-content: space-between;
column-gap: 8px;
align-items: center;
justify-content: flex-end;

.progress {
visibility: hidden;
&.saving {
visibility: visible;
}
}
}

.new {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { Router } from '@angular/router';
import { createTestProjectProfile } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-test-data';
import { TextInfo } from 'realtime-server/lib/esm/scriptureforge/models/text-info';
import { DraftUsfmConfig, ParagraphBreakFormat } from 'realtime-server/lib/esm/scriptureforge/models/translate-config';
import {
DraftUsfmConfig,
ParagraphBreakFormat,
QuoteFormat
} from 'realtime-server/lib/esm/scriptureforge/models/translate-config';
import { of } from 'rxjs';
import { anything, deepEqual, mock, verify, when } from 'ts-mockito';
import { ActivatedProjectService } from 'xforge-common/activated-project.service';
Expand Down Expand Up @@ -94,9 +98,10 @@ describe('DraftUsfmFormatComponent', () => {
verify(mockedDraftHandlingService.getDraft(anything(), anything())).thrice();
}));

it('should initialize and default to best guess', fakeAsync(async () => {
it('should initialize and default to best guess and automatic quotes', fakeAsync(async () => {
const env = new TestEnvironment();
expect(env.component.paragraphFormat.value).toBe(ParagraphBreakFormat.BestGuess);
expect(env.component.quoteFormat.value).toBe(QuoteFormat.Automatic);
expect(await env.component.confirmLeave()).toBe(true);
}));

Expand Down Expand Up @@ -143,7 +148,8 @@ describe('DraftUsfmFormatComponent', () => {
env.fixture.detectChanges();
verify(mockedProjectService.onlineSetUsfmConfig(env.projectId, deepEqual(config))).once();
verify(mockedServalAdministration.onlineRetrievePreTranslationStatus(env.projectId)).once();
verify(mockedRouter.navigate(deepEqual(['projects', env.projectId, 'draft-generation']))).never();
verify(mockedNoticeService.show(anything())).once();
verify(mockedRouter.navigate(deepEqual(['projects', env.projectId, 'draft-generation']))).once();
}));

it('should not save if format is empty', fakeAsync(() => {
Expand Down Expand Up @@ -183,6 +189,7 @@ class TestEnvironment {
this.onlineStatusService.setIsOnline(true);
when(mockedNoticeService.show(anything())).thenResolve();
when(mockedDialogService.confirm(anything(), anything(), anything())).thenResolve(true);
when(mockedServalAdministration.onlineRetrievePreTranslationStatus(anything())).thenResolve();
this.setupProject(args.config);
this.fixture = TestBed.createComponent(DraftUsfmFormatComponent);
this.component = this.fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { Router } from '@angular/router';
import { translate, TranslocoModule } from '@ngneat/transloco';
import { Delta } from 'quill';
import { TextInfo } from 'realtime-server/lib/esm/scriptureforge/models/text-info';
import { DraftUsfmConfig, ParagraphBreakFormat } from 'realtime-server/lib/esm/scriptureforge/models/translate-config';
import {
DraftUsfmConfig,
ParagraphBreakFormat,
QuoteFormat
} from 'realtime-server/lib/esm/scriptureforge/models/translate-config';
import { combineLatest, first, Subject, switchMap } from 'rxjs';
import { ActivatedProjectService } from 'xforge-common/activated-project.service';
import { DataLoadingComponent } from 'xforge-common/data-loading-component';
Expand Down Expand Up @@ -59,12 +63,17 @@ export class DraftUsfmFormatComponent extends DataLoadingComponent implements Af
chapters: number[] = [];
isInitializing: boolean = true;
paragraphBreakFormat = ParagraphBreakFormat;
quoteStyleFormat = QuoteFormat;

paragraphFormat = new FormControl<ParagraphBreakFormat>(ParagraphBreakFormat.BestGuess);
quoteFormat = new FormControl<QuoteFormat>(QuoteFormat.Automatic);
usfmFormatForm: FormGroup = new FormGroup({
paragraphFormat: this.paragraphFormat
paragraphFormat: this.paragraphFormat,
quoteFormat: this.quoteFormat
});

protected saving = false;

private updateDraftConfig$: Subject<DraftUsfmConfig | undefined> = new Subject<DraftUsfmConfig | undefined>();
private lastSavedState?: DraftUsfmConfig;

Expand Down Expand Up @@ -167,14 +176,18 @@ export class DraftUsfmFormatComponent extends DataLoadingComponent implements Af
if (this.projectId == null || !this.isOnline || this.currentFormat == null) return;

try {
this.saving = true;
await this.projectService.onlineSetUsfmConfig(this.projectId, this.currentFormat);
this.lastSavedState = this.currentFormat;
// not awaited so that the user is directed to the draft generation page
this.servalAdministration.onlineRetrievePreTranslationStatus(this.projectId).then(() => {
this.router.navigate(['projects', this.projectId, 'draft-generation']);
this.noticeService.show(translate('draft_usfm_format.changes_have_been_saved'));
});
} catch {
this.noticeService.showError(translate('draft_usfm-format.failed_to_save'));
} finally {
this.saving = false;
}
}

Expand All @@ -189,7 +202,8 @@ export class DraftUsfmFormatComponent extends DataLoadingComponent implements Af

private setUsfmConfig(config?: DraftUsfmConfig): void {
this.usfmFormatForm.setValue({
paragraphFormat: config?.paragraphFormat ?? ParagraphBreakFormat.BestGuess
paragraphFormat: config?.paragraphFormat ?? ParagraphBreakFormat.BestGuess,
quoteFormat: QuoteFormat.Automatic
});
this.lastSavedState = this.currentFormat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,17 +335,18 @@
"changes_have_been_saved": "Changes have been saved",
"cancel": "Cancel",
"connect_to_the_internet": "Please connect to the internet to change the USFM format for your draft",
"draft_format_description": "Your draft has completed. However, there are some formatting options that you can choose before using your draft.",
"draft_format_description": "The draft has been created. Here are some formatting options for the text. You can try each option to see the difference it makes.",
"draft_format_options": "Format draft",
"failed_to_save": "Failed to save changes. Try again later.",
"new": "New",
"option_best_guess": "Best guess",
"option_best_guess_description": "Mid-verse paragraph breaks in the source will be placed at the best guess of where they should be in the draft.",
"option_best_guess_description": "Line breaks in the source will be placed at the best guess of where they should be in the draft. Recommended for most projects.",
"option_end": "Move to end",
"option_end_description": "Mid-verse paragraph breaks in the source will be moved to the end of the verse in the draft.",
"option_end_description": "Line breaks in the source will be moved to the end of the verse.",
"option_remove": "Remove",
"option_remove_description": "Mid-verse paragraph breaks in the source will be omitted in the draft.",
"paragraph_break_description": "Scripture Forge translates each verse as a whole for best text quality. Choose how the paragraph breaks from the source verses are placed.",
"paragraph_break_title": "Mid-verse paragraph breaks",
"option_remove_description": "Line breaks in the source will be omitted from the draft.",
"line_breaks_description": "Scripture Forge translates complete verses, without line breaks, because this gives the best draft. Choose where to place the line breaks from the source.",
"line_breaks_title": "Line breaks",
"save_changes": "Save"
},
"editor": {
Expand Down
Loading