-
Notifications
You must be signed in to change notification settings - Fork 5
feat(Authoring): Translate with AI #2272
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
Aaron-Detre
wants to merge
9
commits into
develop
Choose a base branch
from
translate-with-ai
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8231469
Translation for basic translatable input and translatable textarea
Aaron-Detre e92a4f1
Fixed issues with translatable input and textarea
Aaron-Detre 8441e2c
Translation for HTML component with do-not-translate tags for HTML tags
Aaron-Detre 19571a6
Failed to fix the bug of multiple fields getting overwritten by the s…
Aaron-Detre da2940d
Merge branch 'develop' into translate-with-ai
Aaron-Detre 36f9019
Fixed failing test
Aaron-Detre ab11e58
Updated messages
github-actions[bot] e7f5f7a
Added test for getTranslationSuggestion()
Aaron-Detre ec3d2b4
Merge branch 'translate-with-ai' of https://github.com/WISE-Community…
Aaron-Detre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...l/components/translation-suggestions-dialog/translation-suggestions-dialog.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <mat-dialog-content> | ||
| <p> | ||
| <b>{{ this.data.defaultLanguage }} text</b> | ||
| </p> | ||
| <p class="text-content">{{ this.data.defaultLanguageContent }}</p> | ||
| <p> | ||
| <b>{{ this.data.currentLanguage }} text (current translation)</b> | ||
| </p> | ||
| <p class="text-content">{{ this.data.currentLanguageContent }}</p> | ||
| <p> | ||
| <b>{{ this.data.currentLanguage }} text (AI suggested translation)</b> | ||
| </p> | ||
| <p class="text-content">{{ this.translation }}</p> | ||
| <p class="replace-translation"> | ||
| Do you want to replace the current translation with the AI suggested translation? | ||
| </p> | ||
| </mat-dialog-content> | ||
| <mat-dialog-actions align="start"> | ||
| <button mat-raised-button (click)="onClose(true)">Replace</button> | ||
| <button mat-raised-button (click)="onClose(false)">Cancel</button> | ||
| </mat-dialog-actions> |
7 changes: 7 additions & 0 deletions
7
...l/components/translation-suggestions-dialog/translation-suggestions-dialog.component.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .text-content { | ||
| margin-left: 15px; | ||
| } | ||
|
|
||
| .replace-translation { | ||
| margin-top: 20px; | ||
| } |
35 changes: 35 additions & 0 deletions
35
...omponents/translation-suggestions-dialog/translation-suggestions-dialog.component.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
| import { TeacherProjectTranslationService } from '../../../services/teacherProjectTranslationService'; | ||
| import { TranslationSuggestionsDialogComponent } from './translation-suggestions-dialog.component'; | ||
| import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; | ||
| import { MockProvider } from 'ng-mocks'; | ||
| import { of } from 'rxjs'; | ||
|
|
||
| describe('TranslationSuggestionsDialogComponent', () => { | ||
| let component: TranslationSuggestionsDialogComponent; | ||
| let fixture: ComponentFixture<TranslationSuggestionsDialogComponent>; | ||
|
|
||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ | ||
| imports: [TranslationSuggestionsDialogComponent], | ||
| providers: [ | ||
| MockProvider(TeacherProjectTranslationService), | ||
| { provide: MAT_DIALOG_DATA, useValue: {} }, | ||
| { provide: MatDialogRef, useValue: {} } | ||
| ] | ||
| }).compileComponents(); | ||
|
|
||
| spyOn( | ||
| TestBed.inject(TeacherProjectTranslationService), | ||
| 'getTranslationSuggestion' | ||
| ).and.returnValue(of('Example translated text')); | ||
|
|
||
| fixture = TestBed.createComponent(TranslationSuggestionsDialogComponent); | ||
| component = fixture.componentInstance; | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| it('should create', () => { | ||
| expect(component).toBeTruthy(); | ||
| }); | ||
| }); | ||
58 changes: 58 additions & 0 deletions
58
...ool/components/translation-suggestions-dialog/translation-suggestions-dialog.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { Component, inject } from '@angular/core'; | ||
| import { FormsModule } from '@angular/forms'; | ||
| import { MatButtonModule } from '@angular/material/button'; | ||
| import { | ||
| MAT_DIALOG_DATA, | ||
| MatDialogActions, | ||
| MatDialogContent, | ||
| MatDialogRef | ||
| } from '@angular/material/dialog'; | ||
| import { MatFormFieldModule } from '@angular/material/form-field'; | ||
| import { MatInputModule } from '@angular/material/input'; | ||
| import { TeacherProjectTranslationService } from '../../../services/teacherProjectTranslationService'; | ||
|
|
||
| interface TranslationSuggestionsDialogData { | ||
| defaultLanguage: string; | ||
| currentLanguage: string; | ||
| defaultLanguageContent: string; | ||
| currentLanguageContent?: string; | ||
| } | ||
|
|
||
| @Component({ | ||
| selector: 'translation-suggestions-dialog', | ||
| imports: [ | ||
| MatFormFieldModule, | ||
| MatInputModule, | ||
| FormsModule, | ||
| MatButtonModule, | ||
| MatDialogContent, | ||
| MatDialogActions | ||
| ], | ||
| templateUrl: './translation-suggestions-dialog.component.html', | ||
| styleUrl: './translation-suggestions-dialog.component.scss' | ||
| }) | ||
| export class TranslationSuggestionsDialogComponent { | ||
| readonly dialogRef = inject(MatDialogRef<TranslationSuggestionsDialogComponent>); | ||
| readonly data = inject<TranslationSuggestionsDialogData>(MAT_DIALOG_DATA); | ||
| protected translation; | ||
|
|
||
| constructor(protected projectTranslationService: TeacherProjectTranslationService) { | ||
| this.generateTranslationSuggestion(); | ||
| } | ||
|
|
||
| private generateTranslationSuggestion(): void { | ||
| this.projectTranslationService | ||
| .getTranslationSuggestion( | ||
| this.data.defaultLanguage, | ||
| this.data.currentLanguage, | ||
| this.data.defaultLanguageContent | ||
| ) | ||
| .subscribe((suggestedTranslation: string) => { | ||
| this.translation = suggestedTranslation; | ||
| }); | ||
| } | ||
|
|
||
| protected onClose(saveTranslation: boolean): void { | ||
| this.dialogRef.close(saveTranslation && this.translation); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.