Skip to content

Commit 31efa74

Browse files
committed
if there is only one ad, we don't want to see "Ad 1 of 1"
1 parent a8908bf commit 31efa74

10 files changed

Lines changed: 45 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [Unreleased]
9+
10+
### Added
11+
12+
- New `AdCounterLabelConfig.adLabelIfOneAd` option: message shown while an ad is playing when the ad break contains only a single ad.
13+
14+
### Changed
15+
16+
- `AdCounterLabel` now displays the `adLabelIfOneAd` message ("Advertisement") for single-ad ad breaks instead of the "Ad 1 of 1" count.
17+
818
## [4.17.0] - 2026-07-02
919

1020
### Added

spec/components/ads/AdCounterLabel.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,20 @@ describe('AdCounterLabel', () => {
4747
adCountChangedDispatcher.dispatch(null, { currentAdIndex: 0, totalNumberOfAds: 0 });
4848
expect(adCounterLabel.getText()).toBe('');
4949
});
50+
51+
it('shows the single-ad label when the ad break contains only one ad', () => {
52+
adCounterLabel = new AdCounterLabel({ adLabelIfOneAd: 'Anzeige' });
53+
adCounterLabel.configure(playerMock, uiInstanceManagerMock);
54+
55+
adCountChangedDispatcher.dispatch(null, { currentAdIndex: 1, totalNumberOfAds: 1 });
56+
expect(adCounterLabel.getText()).toBe('Anzeige');
57+
});
58+
59+
it('falls back to the default localized single-ad label', () => {
60+
adCounterLabel = new AdCounterLabel();
61+
adCounterLabel.configure(playerMock, uiInstanceManagerMock);
62+
63+
adCountChangedDispatcher.dispatch(null, { currentAdIndex: 1, totalNumberOfAds: 1 });
64+
expect(adCounterLabel.getText()).toBe('Advertisement');
65+
});
5066
});

src/ts/components/ads/AdCounterLabel.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ export interface AdCounterLabelConfig extends LabelConfig {
1212
* Supported placeholders: look at {@link StringUtils.replaceAdMessagePlaceholders}
1313
*/
1414
adCountOutOfTotal?: LocalizableText;
15+
/**
16+
* Message displayed during an ad if only one ad is in the adbreak.
17+
* Supported placeholders: look at {@link StringUtils.replaceAdMessagePlaceholders}
18+
*/
19+
adLabelIfOneAd?: LocalizableText;
1520
}
1621

1722
/**
@@ -31,6 +36,7 @@ export class AdCounterLabel extends Label<AdCounterLabelConfig> {
3136
{
3237
cssClass: 'ui-label-ad-counter',
3338
adCountOutOfTotal: i18n.getLocalizer('ads.adNumberOfTotal'),
39+
adLabelIfOneAd: i18n.getLocalizer('ads.adLabelIfOne'),
3440
},
3541
this.config,
3642
);
@@ -79,14 +85,13 @@ export class AdCounterLabel extends Label<AdCounterLabelConfig> {
7985
return;
8086
}
8187

88+
const message =
89+
totalNumberOfAds > 1
90+
? i18n.performLocalization(this.config.adCountOutOfTotal)
91+
: i18n.performLocalization(this.config.adLabelIfOneAd);
92+
8293
this.setText(
83-
StringUtils.replaceAdMessagePlaceholders(
84-
i18n.performLocalization(this.config.adCountOutOfTotal),
85-
this.player,
86-
undefined,
87-
currentAdIndex,
88-
totalNumberOfAds,
89-
),
94+
StringUtils.replaceAdMessagePlaceholders(message, this.player, undefined, currentAdIndex, totalNumberOfAds),
9095
);
9196
}
9297
}

src/ts/localization/i18n.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export interface Vocabulary {
9595
'ads.skip': string;
9696
'ads.skippableIn': string;
9797
'ads.adNumberOfTotal': string;
98+
'ads.adLabelIfOne': string;
9899
pictureInPicture: string;
99100
appleAirplay: string;
100101
googleCast: string;

src/ts/localization/languages/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"ads.skip": "Überspringen",
4949
"ads.skippableIn": "Überspringen in {remainingTime}",
5050
"ads.adNumberOfTotal": "Anzeige {activeAdIndex} von {totalAdsCount}",
51+
"ads.adLabelIfOne": "Anzeige",
5152
"settings": "Einstellungen",
5253
"fullscreen": "Vollbild",
5354
"speed": "Geschwindigkeit",

src/ts/localization/languages/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"ads.skip": "Skip",
4949
"ads.skippableIn": "Skip ad in {remainingTime}",
5050
"ads.adNumberOfTotal": "Ad {activeAdIndex} of {totalAdsCount}",
51+
"ads.adLabelIfOne": "Advertisement",
5152
"settings": "Settings",
5253
"fullscreen": "Fullscreen",
5354
"speed": "Speed",

src/ts/localization/languages/es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"ads.skip": "Saltar",
4949
"ads.skippableIn": "Saltar anuncio en {remainingTime}",
5050
"ads.adNumberOfTotal": "Anuncio {activeAdIndex} de {totalAdsCount}",
51+
"ads.adLabelIfOne": "Anuncio",
5152
"settings": "Configuración",
5253
"fullscreen": "Pantalla Completa",
5354
"speed": "Velocidad",

src/ts/localization/languages/fr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"ads.skip": "Passer",
4949
"ads.skippableIn": "Passer l'annonce dans {remainingTime}",
5050
"ads.adNumberOfTotal": "Annonce {activeAdIndex} sur {totalAdsCount}",
51+
"ads.adLabelIfOne": "Annonce",
5152
"settings": "Réglages",
5253
"fullscreen": "Plein écran",
5354
"speed": "Vitesse",

src/ts/localization/languages/nl.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"ads.skip": "Overslaan",
4949
"ads.skippableIn": "Advertentie overslaan over {remainingTime}",
5050
"ads.adNumberOfTotal": "Advertentie {activeAdIndex} van {totalAdsCount}",
51+
"ads.adLabelIfOne": "Advertentie",
5152
"settings": "Instellingen",
5253
"fullscreen": "Volledig scherm",
5354
"speed": "Snelheid",

src/ts/localization/languages/pt.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"ads.skip": "Ignorar",
4949
"ads.skippableIn": "Ignorar anúncio em {remainingTime}",
5050
"ads.adNumberOfTotal": "Anúncio {activeAdIndex} de {totalAdsCount}",
51+
"ads.adLabelIfOne": "Anúncio",
5152
"settings": "Definições",
5253
"fullscreen": "Ecrã inteiro",
5354
"speed": "Velocidade",

0 commit comments

Comments
 (0)