Translation rework: fixes

This commit is contained in:
Adina Țeudan 2021-07-22 14:47:56 +03:00
parent f3ebeb841a
commit 297f55493c
16 changed files with 96 additions and 54 deletions

View File

@ -7,6 +7,7 @@ import { Router } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { FileDownloadService } from '@upload-download/services/file-download.service';
import { TranslateService } from '@ngx-translate/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
interface MenuItem {
name: string;
@ -22,23 +23,23 @@ interface MenuItem {
export class BaseScreenComponent {
readonly userMenuItems: MenuItem[] = [
{
name: 'top-bar.navigation-items.my-account.children.my-profile',
name: _('top-bar.navigation-items.my-account.children.my-profile'),
routerLink: '/main/my-profile',
show: true
},
{
name: 'top-bar.navigation-items.my-account.children.admin',
name: _('top-bar.navigation-items.my-account.children.admin'),
routerLink: '/main/admin',
show: this.permissionsService.isManager() || this.permissionsService.isUserAdmin(),
action: this.appStateService.reset
},
{
name: 'top-bar.navigation-items.my-account.children.downloads',
name: _('top-bar.navigation-items.my-account.children.downloads'),
routerLink: '/main/downloads',
show: this.permissionsService.isUser()
},
{
name: 'top-bar.navigation-items.my-account.children.trash',
name: _('top-bar.navigation-items.my-account.children.trash'),
routerLink: '/main/admin/trash',
show: this.permissionsService.isManager() || this.permissionsService.isUserAdmin()
}

View File

@ -12,7 +12,7 @@
class="item"
routerLinkActive="active"
>
{{ item.label || item.screen | translate }}
{{ item.label | translate }}
</div>
</ng-container>
</redaction-side-nav>

View File

@ -2,6 +2,7 @@ import { Component, Input } from '@angular/core';
import { PermissionsService } from '@services/permissions.service';
import { UserPreferenceService } from '@services/user-preference.service';
import { AppStateService } from '@state/app-state.service';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@Component({
selector: 'redaction-admin-side-nav',
@ -18,25 +19,25 @@ export class AdminSideNavComponent {
onlyAdmin?: boolean;
onlyManager?: boolean;
userManagerOnly?: boolean;
label?: string;
label: string;
}[];
} = {
settings: [
{ screen: 'dossier-templates', onlyManager: true },
{ screen: 'digital-signature', onlyAdmin: true },
{ screen: 'license-info', label: 'license-information', onlyAdmin: true },
{ screen: 'audit', onlyAdmin: true },
{ screen: 'users', label: 'user-management', userManagerOnly: true },
{ screen: 'smtp-config', label: 'configurations', onlyAdmin: true }
{ screen: 'dossier-templates', label: _('dossier-templates'), onlyManager: true },
{ screen: 'digital-signature', label: _('digital-signature'), onlyAdmin: true },
{ screen: 'license-info', label: _('license-information'), onlyAdmin: true },
{ screen: 'audit', label: _('audit'), onlyAdmin: true },
{ screen: 'users', label: _('user-management'), userManagerOnly: true },
{ screen: 'smtp-config', label: _('configurations'), onlyAdmin: true }
],
'dossier-templates': [
{ screen: 'dictionaries' },
{ screen: 'rules', onlyDevMode: true, label: 'rule-editor' },
{ screen: 'default-colors' },
{ screen: 'watermark' },
{ screen: 'file-attributes' },
{ screen: 'dossier-attributes' },
{ screen: 'reports', onlyDevMode: true }
{ screen: 'dictionaries', label: _('dictionaries') },
{ screen: 'rules', onlyDevMode: true, label: _('rule-editor') },
{ screen: 'default-colors', label: _('default-colors') },
{ screen: 'watermark', label: _('watermark') },
{ screen: 'file-attributes', label: _('file-attributes') },
{ screen: 'dossier-attributes', label: _('dossier-attributes') },
{ screen: 'reports', label: _('reports'), onlyDevMode: true }
]
};

View File

@ -23,7 +23,7 @@
[config]="chartData"
[radius]="63"
[strokeWidth]="15"
[subtitle]="'user-stats.chart.users'"
[subtitle]="'user-stats.chart.users' | translate"
direction="row"
totalType="sum"
></redaction-simple-doughnut-chart>

View File

@ -163,7 +163,7 @@
[counterText]="'dictionary-listing.stats.charts.entries' | translate"
[radius]="82"
[strokeWidth]="15"
[subtitle]="'dictionary-listing.stats.charts.types'"
[subtitle]="'dictionary-listing.stats.charts.types' | translate"
totalType="count"
></redaction-simple-doughnut-chart>
</div>

View File

@ -11,6 +11,7 @@ import { Toaster } from '@services/toaster.service';
import { ActivatedRoute } from '@angular/router';
import { BASE_HREF } from '../../../../tokens';
import { stampPDFPage } from '../../../../utils/page-stamper';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
export const DEFAULT_WATERMARK: WatermarkModelRes = {
text: null,
@ -82,9 +83,11 @@ export class WatermarkScreenComponent implements OnInit {
observable.toPromise().then(
() => {
this._loadWatermark();
this._toaster.success(watermark.text ? 'watermark-screen.action.change-success' : 'watermark-screen.action.delete-success');
this._toaster.success(
watermark.text ? _('watermark-screen.action.change-success') : _('watermark-screen.action.delete-success')
);
},
() => this._toaster.error('watermark-screen.action.error')
() => this._toaster.error(_('watermark-screen.action.error'))
);
}

View File

@ -45,7 +45,7 @@
[config]="documentsChartData"
[radius]="63"
[strokeWidth]="15"
[subtitle]="'dossier-overview.dossier-details.charts.documents-in-dossier'"
[subtitle]="'dossier-overview.dossier-details.charts.documents-in-dossier' | translate"
direction="row"
></redaction-simple-doughnut-chart>
</div>

View File

@ -3,7 +3,7 @@
[config]="dossiersChartData"
[radius]="80"
[strokeWidth]="15"
[subtitle]="'dossier-listing.stats.charts.dossiers'"
[subtitle]="'dossier-listing.stats.charts.dossiers' | translate"
></redaction-simple-doughnut-chart>
<div class="dossier-stats-container">
@ -29,6 +29,6 @@
[config]="documentsChartData"
[radius]="80"
[strokeWidth]="15"
[subtitle]="'dossier-listing.stats.charts.total-documents'"
[subtitle]="'dossier-listing.stats.charts.total-documents' | translate"
></redaction-simple-doughnut-chart>
</div>

View File

@ -29,6 +29,7 @@ import { ScreenStateService } from '@shared/services/screen-state.service';
import { BaseListingComponent } from '@shared/base/base-listing.component';
import { SortingService } from '@services/sorting.service';
import { TableColConfig } from '@shared/components/table-col-name/table-col-name.component';
import { workloadTranslations } from '../../translations/workload-translations';
const isLeavingScreen = event => event instanceof NavigationStart && event.url !== '/main/dossiers';
@ -230,7 +231,7 @@ export class DossierListingScreenComponent
const needsWorkFilters = [...allDistinctNeedsWork].map<FilterModel>(type => ({
key: type,
label: `filter.${type}`
label: workloadTranslations[type]
}));
this.filterService.addFilterGroup({

View File

@ -32,6 +32,7 @@ import { LoadingService } from '@services/loading.service';
import { DossierAttributesService } from '@shared/services/controller-wrappers/dossier-attributes.service';
import { DossierAttributeWithValue } from '@models/dossier-attributes.model';
import { UserPreferenceService } from '@services/user-preference.service';
import { workloadTranslations } from '../../translations/workload-translations';
@Component({
templateUrl: './dossier-overview-screen.component.html',
@ -294,7 +295,7 @@ export class DossierOverviewScreenComponent
const needsWorkFilters = [...allDistinctNeedsWork].map<FilterModel>(item => ({
key: item,
label: this._translateService.instant('filter.' + item)
label: workloadTranslations[item]
}));
this.filterService.addFilterGroup({

View File

@ -0,0 +1,11 @@
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
export const workloadTranslations: { [key: string]: string } = {
analysis: _('filter.analysis'),
hint: _('filter.hint'),
image: _('filter.image'),
none: _('filter.none'),
redaction: _('filter.redaction'),
suggestion: _('filter.suggestion'),
updated: _('filter.updated')
};

View File

@ -19,7 +19,7 @@
<div [style]="'height: ' + size + 'px; width: ' + size + 'px; padding: ' + strokeWidth + 'px;'" class="text-container">
<div class="heading-xl">{{ displayedDataTotal }}</div>
<div class="mt-5">{{ subtitle | translate }}</div>
<div class="mt-5">{{ subtitle }}</div>
</div>
<div class="breakdown-container">

View File

@ -31,23 +31,17 @@ export class DatePipe extends BaseDatePipe implements PipeTransform {
const minutesFromNow = date.diff(now, 'minutes');
const minutesLeft = minutesFromNow - HOURS_IN_A_DAY * MINUTES_IN_AN_HOUR * daysLeft;
if (daysLeft === 0 && hoursLeft === 0 && minutesLeft > 0) return this._translate('time.less-than-an-hour');
if (daysLeft === 0 && hoursLeft === 0 && minutesLeft > 0) return this._translateService.instant('time.less-than-an-hour');
const hoursSuffix = this._translate(`time.hour${hoursLeft === 1 ? '' : 's'}`);
const hoursDisplay = `${hoursLeft} ${hoursSuffix}`;
const hoursDisplay = this._translateService.instant('time.hours', { hours: hoursLeft });
if (daysLeft === 0 && hoursLeft > 0) return hoursDisplay;
const daysSuffix = this._translate(`time.day${daysLeft === 1 ? '' : 's'}`);
const daysDisplay = `${daysLeft} ${daysSuffix}`;
const daysDisplay = this._translateService.instant('time.days', { days: daysLeft });
if (daysLeft > 0 && hoursLeft > 0) return `${daysDisplay} ${hoursDisplay}`;
if (daysLeft > 0) return daysDisplay;
return this._translate(`time.no-time-left`);
}
private _translate(value: string, params?: { [key: string]: string }) {
return this._translateService.instant(value, params);
return this._translateService.instant(`time.no-time-left`);
}
}

View File

@ -4,6 +4,6 @@ export class REDMissingTranslationHandler implements MissingTranslationHandler {
handle(params: MissingTranslationHandlerParams): any {
const missingKey = params.key;
console.error('Missing translation: ' + missingKey);
return missingKey;
return `?${missingKey}?`;
}
}

View File

@ -1236,21 +1236,11 @@
},
"title": "Configure SMTP Account"
},
"sorting": {
"alphabetically": "Alphabetically",
"custom": "Custom",
"number-of-analyses": "Number of analyses",
"number-of-pages": "Number of pages",
"oldest": "Oldest",
"recent": "Recent"
},
"submitted": "Submitted",
"suggestion": "Suggestion for redaction",
"time": {
"day": "day",
"days": "days",
"hour": "hour",
"hours": "hours",
"hours": "{hours} {hours, plural, one{hour} other{hours}}",
"days": "{days} {days, plural, one{day} other{days}}",
"less-than-an-hour": "< 1 hour",
"no-time-left": "Time to restore already passed"
},

View File

@ -358,6 +358,7 @@
}
},
"content": "",
"default-colors": "",
"default-colors-screen": {
"action": {
"edit": ""
@ -382,6 +383,7 @@
}
},
"dev-mode": "",
"dictionaries": "",
"dictionary-listing": {
"action": {
"delete": "",
@ -402,7 +404,8 @@
"search": "",
"stats": {
"charts": {
"entries": ""
"entries": "",
"types": ""
}
},
"table-col-names": {
@ -474,6 +477,7 @@
"number": "",
"text": ""
},
"dossier-attributes": "",
"dossier-attributes-listing": {
"action": {
"edit": ""
@ -539,6 +543,10 @@
"search": "",
"stats": {
"analyzed-pages": "",
"charts": {
"dossiers": "",
"total-documents": ""
},
"total-people": ""
},
"table-col-names": {
@ -567,6 +575,9 @@
"image-uploaded": "",
"show-less": ""
},
"charts": {
"documents-in-dossier": ""
},
"description": "",
"dictionary": "",
"stats": {
@ -734,6 +745,7 @@
"number": "",
"text": ""
},
"file-attributes": "",
"file-attributes-csv-import": {
"action": {
"cancel-edit-name": "",
@ -878,6 +890,15 @@
"filter-types": "",
"label": ""
},
"filter": {
"analysis": "",
"hint": "",
"image": "",
"none": "",
"redaction": "",
"suggestion": "",
"updated": ""
},
"filters": {
"assigned-people": "",
"dossier-templates": "",
@ -1006,6 +1027,7 @@
"report-type": {
"label": ""
},
"reports": "",
"reports-screen": {
"description": "",
"document-setup-description": "",
@ -1035,6 +1057,7 @@
"red-user-admin": "",
"regular": ""
},
"rule-editor": "",
"rules-screen": {
"revert-changes": "",
"save-changes": ""
@ -1087,18 +1110,28 @@
"subtitle": "",
"title": ""
},
"time": {
"days": "",
"hours": "",
"less-than-an-hour": "",
"no-time-left": ""
},
"top-bar": {
"navigation-items": {
"back": "",
"dossiers": "",
"my-account": {
"children": {
"admin": "",
"downloads": "",
"language": {
"de": "",
"en": "",
"label": ""
},
"logout": ""
"logout": "",
"my-profile": "",
"trash": ""
}
}
}
@ -1180,12 +1213,19 @@
"title": ""
},
"user-stats": {
"chart": {
"users": ""
},
"collapse": "",
"expand": "",
"title": ""
},
"watermark": "",
"watermark-screen": {
"action": {
"change-success": "",
"delete-success": "",
"error": "",
"revert": "",
"save": ""
},