Skip to content

Commit

Permalink
translations: fix string extraction problem
Browse files Browse the repository at this point in the history
* The `marker` function (used to mark a string as extractable for
  translation) cannot be used as enum value. Place these values into the
  manual_translation file.
* Fix translation issues.
* Closes rero/rero-ils#1814.

Co-Authored-by: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai committed May 3, 2021
1 parent 8e85d4c commit 1a149bc
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 78 deletions.
17 changes: 6 additions & 11 deletions projects/admin/src/app/circulation/classes/patron-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,17 @@
/* tslint:disable */
// required as json properties is not lowerCamelCase

import { marker } from '@biesbjerg/ngx-translate-extract-marker';
import * as moment from 'moment';

export function _(str) {
return marker(str);
}

export enum PatronTransactionStatus {
OPEN = _('open'),
CLOSED = _('closed')
OPEN = 'open',
CLOSED = 'closed'
}
export enum PatronTransactionEventType {
FEE = _('fee'),
PAYMENT = _('payment'),
DISPUTE = _('dispute'),
CANCEL = _('cancel')
FEE = 'fee',
PAYMENT = 'payment',
DISPUTE = 'dispute',
CANCEL = 'cancel'
}

export class PatronTransaction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,15 @@ export class PatronTransactionService {
this._recordService.create('patron_transaction_events', record).subscribe(
() => {
this.emitPatronTransactionByPatron(affectedPatron, undefined, 'open');
this._toastService.success(this._translateService.instant(
'{{ type }} registered',
{type: record.type}
));
const translate_type = this._translateService.instant(record.type);
this._toastService.success(this._translateService.instant('{{ type }} registered', {type: translate_type}));
},
(error) => {
const message = '[' + error.status + ' - ' + error.statusText + '] ' + error.error.message;
const translate_type = this._translateService.instant(record.type);
this._toastService.error(
message,
this._translateService.instant(
'{{ type }} creation failed!',
{ type: record.type }
)
this._translateService.instant('{{ type }} creation failed!', { type: translate_type })
);
}
);
Expand Down
14 changes: 4 additions & 10 deletions projects/admin/src/app/classes/ill-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,9 @@
/* tslint:disable */
// required as json properties is not lowerCamelCase

import { marker } from '@biesbjerg/ngx-translate-extract-marker';

export function _(str) {
return marker(str);
}

export enum ILLRequestStatus {
PENDING = _('pending'),
VALIDATED = _('validated'),
DENIED = _('denied'),
CLOSED = _('closed'),
PENDING = 'pending',
VALIDATED = 'validated',
DENIED = 'denied',
CLOSED = 'closed'
}
42 changes: 18 additions & 24 deletions projects/admin/src/app/classes/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,20 @@
/* tslint:disable */
// required as json properties is not lowerCamelCase

import { marker } from '@biesbjerg/ngx-translate-extract-marker';
import { Moment } from 'moment';
import { ItemStatus, User } from '@rero/shared';
import { Loan } from './loans'

export function _(str) {
return marker(str);
}

export enum ItemNoteType {
GENERAL = _('general_note'),
STAFF = _('staff_note'),
CHECKIN = _('checkin_note'),
CHECKOUT = _('checkout_note'),
BINDING = _('binding_note'),
PROVENANCE = _('provenance_note'),
CONDITION = _('condition_note'),
PATRIMONIAL = _('patrimonial_note'),
ACQUISITION = _('acquisition_note'),
GENERAL = 'general_note',
STAFF = 'staff_note',
CHECKIN = 'checkin_note',
CHECKOUT = 'checkout_note',
BINDING = 'binding_note',
PROVENANCE = 'provenance_note',
CONDITION = 'condition_note',
PATRIMONIAL = 'patrimonial_note',
ACQUISITION = 'acquisition_note',
}

export interface Organisation {
Expand All @@ -49,16 +44,15 @@ export interface Document {
}

export enum ItemAction {
checkout = _('checkout'),
checkin = _('checkin'),
request = _('request'),
lose = _('lose'),
receive = _('receive'),
return_missing = _('return_missing'),
// cancel_loan = _('cancel_loan'),
extend_loan = _('extend_loan'),
validate = _('validate'),
no = _('no')
checkout = 'checkout',
checkin = 'checkin',
request = 'request',
lose = 'lose',
receive = 'receive',
return_missing = 'return_missing',
extend_loan = 'extend_loan',
validate = 'validate',
no = 'no'
}

type ItemActionObjectType<R> = {[key in keyof typeof ItemAction]: R };
Expand Down
13 changes: 4 additions & 9 deletions projects/admin/src/app/classes/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@
// required as json properties is not lowerCamelCase

import { WeekDay } from '@angular/common';
import { marker } from '@biesbjerg/ngx-translate-extract-marker';
import * as moment from 'moment';
import { WeekDays } from './week-days';


export function _(str) {
return marker(str);
}

export interface OpeningHours {
day: string;
is_open: boolean;
Expand Down Expand Up @@ -59,10 +54,10 @@ export interface ExceptionDates {
}

export enum NotificationType {
DUE_SOON = _('due_soon'),
RECALL = _('recall'),
OVERDUE = _('overdue'),
AVAILABILITY = _('availability')
DUE_SOON = 'due_soon',
RECALL = 'recall',
OVERDUE = 'overdue',
AVAILABILITY = 'availability'
}

export interface NotificationSettings {
Expand Down
22 changes: 8 additions & 14 deletions projects/admin/src/app/classes/loans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,19 @@
/* tslint:disable */
// required as json properties is not lowerCamelCase

import { marker } from '@biesbjerg/ngx-translate-extract-marker';
import moment, { Moment } from 'moment';


export function _(str) {
return marker(str);
}

// ENUM ========================================================================
/** All possible state about a loan */
export enum LoanState {
CREATED = _('CREATED'),
PENDING = _('PENDING'),
ITEM_ON_LOAN = _('ITEM_ON_LOAN'),
ITEM_RETURNED = _('ITEM_RETURNED'),
ITEM_IN_TRANSIT_FOR_PICKUP = _('ITEM_IN_TRANSIT_FOR_PICKUP'),
ITEM_IN_TRANSIT_TO_HOUSE = _('ITEM_IN_TRANSIT_TO_HOUSE'),
ITEM_AT_DESK = _('ITEM_AT_DESK'),
CANCELLED = _('CANCELLED')
CREATED = 'CREATED',
PENDING = 'PENDING',
ITEM_ON_LOAN = 'ITEM_ON_LOAN',
ITEM_RETURNED = 'ITEM_RETURNED',
ITEM_IN_TRANSIT_FOR_PICKUP = 'ITEM_IN_TRANSIT_FOR_PICKUP',
ITEM_IN_TRANSIT_TO_HOUSE = 'ITEM_IN_TRANSIT_TO_HOUSE',
ITEM_AT_DESK = 'ITEM_AT_DESK',
CANCELLED = 'CANCELLED'
}

// INTERFACE ===================================================================
Expand Down
50 changes: 48 additions & 2 deletions projects/admin/src/manual_translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ _('ordered');
_('pending');
_('received');


// Electronic locator types
_('noInfo');
_('resource');
Expand Down Expand Up @@ -106,6 +105,54 @@ _('webSite');
_('tableOfContents');
_('fullText');

// Enum values
// - patron transaction
_('open');
_('closed');
_('fee');
_('payment');
_('dispute');
_('cancel');
// - ill requests
_('pending');
_('validated');
_('denied');
_('closed');
// - notification type
_('due_soon');
_('recall');
_('overdue');
_('availability');
// - loan state
_('CREATED');
_('PENDING');
_('ITEM_ON_LOAN');
_('ITEM_RETURNED');
_('ITEM_IN_TRANSIT_FOR_PICKUP');
_('ITEM_IN_TRANSIT_TO_HOUSE');
_('ITEM_AT_DESK');
_('CANCELLED');
// - Item note type
_('general_note');
_('staff_note');
_('checkin_note');
_('checkout_note');
_('binding_note');
_('provenance_note');
_('condition_note');
_('patrimonial_note');
_('acquisition_note');
// - Item circulation action
_('checkout');
_('checkin');
_('request');
_('lose');
_('receive');
_('return_missing');
_('extend_loan');
_('validate');
_('no');

// Item Request messages
_('Request not allowed by the circulation policy.');
_('The item is already checked out or requested by this patron.');
Expand Down Expand Up @@ -155,6 +202,5 @@ _('My library');
_('Public interface');
_('Logout');


_('Masked');
_('No masked');

0 comments on commit 1a149bc

Please sign in to comment.