diff --git a/src/components/cardbuilder/cardBuilder.js b/src/components/cardbuilder/cardBuilder.js index 352b38a6a1..6d0c73afe0 100644 --- a/src/components/cardbuilder/cardBuilder.js +++ b/src/components/cardbuilder/cardBuilder.js @@ -4,6 +4,7 @@ * @module components/cardBuilder/cardBuilder */ +import { PersonKind } from '@jellyfin/sdk/lib/generated-client/models/person-kind'; import escapeHtml from 'escape-html'; import browser from 'scripts/browser'; @@ -698,8 +699,26 @@ function getCardFooterText(item, apiClient, options, footerClass, progressHtml, } } - if (options.showPersonRoleOrType && item.Role) { - lines.push(globalize.translate('PersonRole', escapeHtml(item.Role))); + if (options.showPersonRoleOrType && item.Type) { + if (item.Role) { + if ([ PersonKind.Actor, PersonKind.GuestStar ].includes(item.Type)) { + // List actor roles formatted like "as Character Name" + lines.push(globalize.translate('PersonRole', escapeHtml(item.Role))); + } else if (item.Role.toLowerCase() === item.Type.toLowerCase()) { + // Role and Type are the same so use the localized Type + lines.push(escapeHtml(globalize.translate(item.Type))); + } else if (item.Role.toLowerCase().includes(item.Type.toLowerCase())) { + // Avoid duplication if the Role includes the Type (i.e. Executive Producer) + lines.push(escapeHtml(item.Role)); + } else { + // Type and Role are unique so list both (i.e. Writer | Novel) + lines.push(escapeHtml(globalize.translate(item.Type))); + lines.push(escapeHtml(item.Role)); + } + } else { + // No Role so use the localized Type + lines.push(escapeHtml(globalize.translate(item.Type))); + } } }