Skip to content

Commit

Permalink
refactor(showcase): add localization to skip button
Browse files Browse the repository at this point in the history
Refactors the skip button showcase to demonstrate how to add localization directly
through video.js API.
  • Loading branch information
jboix committed Feb 26, 2024
1 parent 5b99bfa commit c440720
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 10 additions & 2 deletions static/showcases/skip-credits.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ <h2>Skip Credits</h2>
this.player.currentTime(timeInterval.endTime);
},
// Set the class for styling and hide the element with 'vjs-hidden'
className: 'pbw-skip-btn vjs-hidden',
// 'vjs-visible-text' allows to show the controlText
className: 'pbw-skip-btn vjs-hidden vjs-visible-text',
// Set the control text for accessibility
controlText: 'Skip'
controlText: `${this.player.localize('skip')} >>`
});
}

Expand All @@ -82,6 +83,13 @@ <h2>Skip Credits</h2>
// Register a plugin to skip credits
pillarbox.registerPlugin('skipButton', SkipButton);

// Add the translations for the button
pillarbox.addLanguage('en', { 'skip': 'Skip' });
pillarbox.addLanguage('fr', { 'skip': 'Passer' });
pillarbox.addLanguage('de', { 'skip': 'Überspringen' });
pillarbox.addLanguage('it', { 'skip': 'Saltare' });
pillarbox.addLanguage('rm', { 'skip': 'Sursiglir' });

// Create a pillarbox player instance with the skipButton plugin
const player = pillarbox(
'video-element-id',
Expand Down
2 changes: 0 additions & 2 deletions static/showcases/skip-showcase.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
position: absolute;
right: var(--size-5);
bottom: var(--size-9);
width: var(--size-10);
height: var(--size-6);
color: white;
background-color: rgb(0 0 0 / 70%);
Expand All @@ -13,6 +12,5 @@

.vjs-icon-placeholder::before {
font-size: var(--font-size-1);
content: 'Skip >>';
}
}

0 comments on commit c440720

Please sign in to comment.