Skip to content
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

translations: fix show more item link #370

Merged
merged 1 commit into from
Sep 21, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
{{ 'Show more' | translate }} ...
</a>
<span class="pl-2 pt-1 small text-secondary">({{ showMoreItemsCounter('issue' | translate, 'issues' | translate) }})</span>
<span class="pl-2 pt-1 small text-secondary">({{ showMoreItemsCounter('issue') }})</span>
</div>
</ng-container>
<ng-template #no_items>
Expand Down Expand Up @@ -113,7 +113,7 @@
<i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
{{ 'Show more' | translate }} ...
</a>
<span class="pl-2 pt-1 small text-secondary">({{ showMoreItemsCounter('item' | translate, 'items' | translate) }})</span>
<span class="pl-2 pt-1 small text-secondary">({{ showMoreItemsCounter('item') }})</span>
</div>
</ng-container>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,25 @@ export class HoldingComponent implements OnInit, OnDestroy {

/**
* Get the counter string about not loaded items
* @param itemType: the type of item related to the counter
* @return the string to display with the 'show more' link
*/
showMoreItemsCounter(itemType: string, pluralForm?: string) {
const plural = (pluralForm == null) ? itemType + 's' : pluralForm;
const additionalIssueCounter = this.totalItemsCounter - this.displayItemsCounter;
itemType = (additionalIssueCounter > 1) ? plural : itemType;
return additionalIssueCounter + ' ' + this._translateService.instant('hidden') + ' ' + itemType;
showMoreItemsCounter(itemType: string) {
const messages = {
issue: {
singular: '{{ counter }} hidden issue',
plural: '{{ counter }} hidden issues'
},
default: {
singular: '{{ counter }} hidden item',
plural: '{{ counter }} hidden items'
}
};
const message = messages.hasOwnProperty(itemType) ? messages[itemType] : messages.default;
const additionalItemCounter = this.totalItemsCounter - this.displayItemsCounter;
return this._translateService.instant(
(additionalItemCounter === 1) ? message.singular : message.plural,
{counter: additionalItemCounter}
);
zannkukai marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ export class SerialHoldingDetailViewComponent implements OnInit {
get showMoreIssuesCounter() {
const additionalIssueCounter = this.totalReceivedItems - this.receivedItems.length;
return (additionalIssueCounter === 1)
? '1 ' + this._translateService.instant('hidden issue')
: additionalIssueCounter + ' ' + this._translateService.instant('hidden issues');
? this._translateService.instant('1 hidden issue')
: this._translateService.instant('{{ counter }} hidden issues',
{counter: additionalIssueCounter});
}

/**
Expand Down