« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateAlbumReleaseInfo.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateAlbumReleaseInfo.js')
-rw-r--r--src/content/dependencies/generateAlbumReleaseInfo.js124
1 files changed, 67 insertions, 57 deletions
diff --git a/src/content/dependencies/generateAlbumReleaseInfo.js b/src/content/dependencies/generateAlbumReleaseInfo.js
index 26e2e160..28227f45 100644
--- a/src/content/dependencies/generateAlbumReleaseInfo.js
+++ b/src/content/dependencies/generateAlbumReleaseInfo.js
@@ -59,61 +59,71 @@ export default {
     return data;
   },
 
-  generate(data, relations, {html, language}) {
-    return html.tags([
-      html.tag('p',
-        {[html.onlyIfContent]: true},
-        {[html.joinChildren]: html.tag('br')},
-
-        [
-          relations.artistContributionsLine
-            .slots({stringKey: 'releaseInfo.by'}),
-
-          relations.coverArtistContributionsLine
-            .slots({stringKey: 'releaseInfo.coverArtBy'}),
-
-          relations.wallpaperArtistContributionsLine
-            .slots({stringKey: 'releaseInfo.wallpaperArtBy'}),
-
-          relations.bannerArtistContributionsLine
-            .slots({stringKey: 'releaseInfo.bannerArtBy'}),
-
-          language.$('releaseInfo.released', {
-            [language.onlyIfOptions]: ['date'],
-            date: language.formatDate(data.date),
-          }),
-
-          language.$('releaseInfo.artReleased', {
-            [language.onlyIfOptions]: ['date'],
-            date: language.formatDate(data.coverArtDate),
-          }),
-
-          language.$('releaseInfo.duration', {
-            [language.onlyIfOptions]: ['duration'],
-            duration:
-              language.formatDuration(data.duration, {
-                approximate: data.durationApproximate,
-              }),
-          }),
-        ]),
-
-      html.tag('p',
-        {[html.onlyIfContent]: true},
-        language.$('releaseInfo.listenOn', {
-          [language.onlyIfOptions]: ['links'],
-          links:
-            language.formatDisjunctionList(
-              relations.externalLinks
-                .map(link =>
-                  link.slot('context', [
-                    'album',
-                    (data.numTracks === 0
-                      ? 'albumNoTracks'
-                   : data.numTracks === 1
-                      ? 'albumOneTrack'
-                      : 'albumMultipleTracks'),
-                  ]))),
-        })),
-    ]);
-  },
+  generate: (data, relations, {html, language}) =>
+    language.encapsulate('releaseInfo', capsule =>
+      html.tags([
+        html.tag('p',
+          {[html.onlyIfContent]: true},
+          {[html.joinChildren]: html.tag('br')},
+
+          [
+            relations.artistContributionsLine.slots({
+              stringKey: capsule + '.by',
+              chronologyKind: 'album',
+            }),
+
+            relations.coverArtistContributionsLine.slots({
+              stringKey: capsule + '.coverArtBy',
+              chronologyKind: 'coverArt',
+            }),
+
+            relations.wallpaperArtistContributionsLine.slots({
+              stringKey: capsule + '.wallpaperArtBy',
+              chronologyKind: 'wallpaperArt',
+            }),
+
+            relations.bannerArtistContributionsLine.slots({
+              stringKey: capsule + '.bannerArtBy',
+              chronologyKind: 'bannerArt',
+            }),
+
+            language.$(capsule, 'released', {
+              [language.onlyIfOptions]: ['date'],
+              date: language.formatDate(data.date),
+            }),
+
+            language.$(capsule, 'artReleased', {
+              [language.onlyIfOptions]: ['date'],
+              date: language.formatDate(data.coverArtDate),
+            }),
+
+            language.$(capsule, 'duration', {
+              [language.onlyIfOptions]: ['duration'],
+              duration:
+                language.formatDuration(data.duration, {
+                  approximate: data.durationApproximate,
+                }),
+            }),
+          ]),
+
+        html.tag('p',
+          {[html.onlyIfContent]: true},
+
+          language.$(capsule, 'listenOn', {
+            [language.onlyIfOptions]: ['links'],
+
+            links:
+              language.formatDisjunctionList(
+                relations.externalLinks
+                  .map(link =>
+                    link.slot('context', [
+                      'album',
+                      (data.numTracks === 0
+                        ? 'albumNoTracks'
+                     : data.numTracks === 1
+                        ? 'albumOneTrack'
+                        : 'albumMultipleTracks'),
+                    ]))),
+          })),
+      ])),
 };