From 1172d9a2b99dfb0560b049d756d1886de613d928 Mon Sep 17 00:00:00 2001 From: alfred-delacosta <132242610+alfred-delacosta@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:06:43 -0400 Subject: [PATCH] Added artist list concatenation for albums that have over 10 artists (#4830) * Added condition to display concatenated text if artist count is over 10. Fixed #4228 * Added string to strings.json. Used globalize.translate() * Moved code to getArtistLinksHtml function * Update src/controllers/itemDetails/index.js Co-authored-by: Bill Thornton * Simplify appending other artists string * Update src/controllers/itemDetails/index.js Co-authored-by: Bill Thornton * Update src/controllers/itemDetails/index.js Co-authored-by: felix920506 * Update src/strings/en-us.json Co-authored-by: felix920506 --------- Co-authored-by: AJ Co-authored-by: Bill Thornton Co-authored-by: felix920506 --- src/controllers/itemDetails/index.js | 16 ++++++++++++---- src/strings/en-us.json | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/controllers/itemDetails/index.js b/src/controllers/itemDetails/index.js index 99dbd8d2ea..584452e6bd 100644 --- a/src/controllers/itemDetails/index.js +++ b/src/controllers/itemDetails/index.js @@ -386,17 +386,25 @@ function reloadUserDataButtons(page, item) { function getArtistLinksHtml(artists, serverId, context) { const html = []; + const numberOfArtists = artists.length; - for (const artist of artists) { + for (let i = 0; i < Math.min(numberOfArtists, 10); i++) { + const artist = artists[i]; const href = appRouter.getRouteUrl(artist, { - context: context, + context, itemType: 'MusicArtist', - serverId: serverId + serverId }); html.push('' + escapeHtml(artist.Name) + ''); } - return html.join(' / '); + let fullHtml = html.join(' / '); + + if (numberOfArtists > 10) { + fullHtml = globalize.translate('AndOtherArtists', fullHtml, numberOfArtists - 10); + } + + return fullHtml; } /** diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 12023468eb..56b6c4f673 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -46,6 +46,7 @@ "AllowTonemappingHelp": "Tone-mapping can transform the dynamic range of a video from HDR to SDR while maintaining image details and colors, which are very important information for representing the original scene. Currently works only with 10bit HDR10, HLG and DoVi videos. This requires the corresponding GPGPU runtime.", "AlwaysPlaySubtitles": "Always Play", "AlwaysPlaySubtitlesHelp": "Subtitles matching the language preference will be loaded regardless of the audio language.", + "AndOtherArtists": "{0} and {1} other artists.", "AnyLanguage": "Any Language", "Anytime": "Anytime", "ApiKeysCaption": "List of the currently enabled API keys",