-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a4d63b
commit 9d1b8a5
Showing
16 changed files
with
317 additions
and
57 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
browserslist | ||
LICENSE | ||
coverage | ||
app | ||
app/* | ||
package-lock.json | ||
.* | ||
*.ico | ||
|
This file contains 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 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 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,20 @@ | ||
import { AbstractControl, ValidatorFn } from '@angular/forms'; | ||
|
||
const parser = new DOMParser(); | ||
|
||
export function xlfElementValidator(source: string): ValidatorFn { | ||
const doc = parser.parseFromString(`<root>${source}</root>`, 'text/xml'); | ||
const placeholders = Array.from<Element>(doc.documentElement.childNodes as any) | ||
.filter(n => n.nodeType !== doc.TEXT_NODE) | ||
.map(p => p.outerHTML); | ||
return !placeholders.length || | ||
source.startsWith('{VAR_PLURAL') || | ||
source.startsWith('{VAR_SELECT') | ||
? () => null | ||
: (control: AbstractControl) => { | ||
const value: string = control.value; | ||
return typeof value !== 'string' || !value || placeholders.every(p => value.indexOf(p) >= 0) | ||
? null | ||
: { placeholders }; | ||
}; | ||
} |
This file contains 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 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 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 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 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 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 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 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,56 @@ | ||
<h2>{{ (unit | async)?.id }}</h2> | ||
|
||
<ng-container *ngIf="form | async as formGroup"> | ||
<form [formGroup]="formGroup"> | ||
<mat-form-field appearance="standard"> | ||
<mat-label>Description</mat-label> | ||
<input matInput formControlName="description" /> | ||
</mat-form-field> | ||
|
||
<mat-form-field appearance="standard"> | ||
<mat-label>Meaning</mat-label> | ||
<input matInput formControlName="meaning" /> | ||
</mat-form-field> | ||
|
||
<mat-form-field appearance="standard"> | ||
<mat-label>Source</mat-label> | ||
<textarea matInput formControlName="source" cdkTextareaAutosize></textarea> | ||
<button | ||
type="button" | ||
mat-icon-button | ||
matSuffix | ||
matTooltip="Copy source to clipboard" | ||
(click)="copySourceToClipboard(formGroup.get('source').value)" | ||
> | ||
<mat-icon>file_copy</mat-icon> | ||
</button> | ||
</mat-form-field> | ||
|
||
<mat-form-field appearance="standard"> | ||
<mat-label>Target</mat-label> | ||
<textarea matInput formControlName="target" cdkTextareaAutosize></textarea> | ||
<mat-hint *ngIf="formGroup.get('target').errors?.placeholders as placeholders" | ||
>Expected {{ placeholders.length }} placeholders | ||
<mat-icon [matTooltip]="placeholders.join('\n')" matTooltipClass="tooltip-linebreak" | ||
>info</mat-icon | ||
> | ||
</mat-hint> | ||
</mat-form-field> | ||
|
||
<mat-form-field appearance="standard"> | ||
<mat-label>State</mat-label> | ||
<mat-select formControlName="state"> | ||
<mat-option *ngIf="formGroup.get('state').value === 'initial'" value="initial" | ||
>Initial</mat-option | ||
> | ||
<mat-option value="translated">Translated</mat-option> | ||
<mat-option value="reviewed">Reviewed</mat-option> | ||
<mat-option value="final">Final</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
</form> | ||
</ng-container> | ||
|
||
<a mat-raised-button color="primary" routerLink="../.." [queryParams]="params | async"> | ||
<mat-icon>keyboard_backspace</mat-icon> Back | ||
</a> |
Oops, something went wrong.