Skip to content

Commit c075ce4

Browse files
authored
Duck Player custom error translations (#1732)
1 parent 7aaca5b commit c075ce4

27 files changed

+1190
-12
lines changed

special-pages/pages/duckplayer/app/components/YouTubeError.jsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { useOpenOnYoutubeHandler } from '../providers/SettingsProvider.jsx';
77

88
import styles from './YouTubeError.module.css';
99
import { useLocale, useYouTubeError } from '../providers/YouTubeErrorProvider';
10-
import { useEnv } from '../../../../shared/components/EnvironmentProvider';
1110

1211
/**
1312
* @typedef {import('../../types/duckplayer').YouTubeError} YouTubeError
@@ -17,12 +16,14 @@ import { useEnv } from '../../../../shared/components/EnvironmentProvider';
1716

1817
/**
1918
* @param {YouTubeError} youtubeError
20-
* @param {string} locale
2119
* @returns {ErrorStrings}
2220
*/
23-
function useErrorStrings(youtubeError, locale) {
21+
function useErrorStrings(youtubeError) {
2422
const { t } = useTypedTranslation();
2523

24+
// This versioning setup exists in case we need to experiment with copy variants in the future. At the moment, v2 is used everywhere.
25+
const version = 'v2';
26+
2627
/**
2728
* @type {Record<string, Partial<Record<YouTubeError, ErrorStrings>> & { unknown: ErrorStrings }>}
2829
*/
@@ -63,8 +64,6 @@ function useErrorStrings(youtubeError, locale) {
6364
},
6465
};
6566

66-
const version = locale === 'en' ? 'v2' : 'v1';
67-
6867
return versions[version]?.[youtubeError] || versions[version]?.['unknown'] || versions['v1']['unknown'];
6968
}
7069

@@ -75,14 +74,13 @@ function useErrorStrings(youtubeError, locale) {
7574
*/
7675
export function YouTubeError({ layout, embed }) {
7776
const youtubeError = useYouTubeError();
78-
const locale = useLocale();
7977
if (!youtubeError) {
8078
return null;
8179
}
8280

8381
const { t } = useTypedTranslation();
8482
const openOnYoutube = useOpenOnYoutubeHandler();
85-
const { heading, messages, variant } = useErrorStrings(youtubeError, locale);
83+
const { heading, messages, variant } = useErrorStrings(youtubeError);
8684
const classes = cn(styles.error, {
8785
[styles.desktop]: layout === 'desktop',
8886
[styles.mobile]: layout === 'mobile',

special-pages/pages/duckplayer/integration-tests/duck-player.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,8 @@ export class DuckPlayerPage {
626626

627627
async didShowGenericErrorInSpanish() {
628628
await expect(this.page.getByTestId('YouTubeErrorContent')).toMatchAriaSnapshot(`
629-
- heading "YouTube no permite que Duck Player cargue este vídeo" [level=1]
630-
- paragraph: YouTube no permite que este vídeo se vea fuera de YouTube.
629+
- heading "Duck Player no puede cargar este vídeo" [level=1]
630+
- paragraph: Este vídeo no se puede ver fuera de YouTube.
631631
- paragraph: Sigues pudiendo ver este vídeo en YouTube, pero sin la privacidad adicional que ofrece Duck Player.
632632
`);
633633
}
@@ -640,6 +640,14 @@ export class DuckPlayerPage {
640640
`);
641641
}
642642

643+
async didShowAgeRestrictedErrorInSpanish() {
644+
await expect(this.page.getByTestId('YouTubeErrorContent')).toMatchAriaSnapshot(`
645+
- heading "Lo sentimos, este vídeo está restringido por edad" [level=1]
646+
- paragraph: Para ver vídeos con restricción de edad, necesitas iniciar sesión en YouTube para verificar tu edad.
647+
- paragraph: Todavía puedes ver este vídeo, pero tendrás que iniciar sesión y verlo en YouTube sin la privacidad adicional de Duck Player.
648+
`);
649+
}
650+
643651
async didShowNoEmbedError() {
644652
await expect(this.page.getByTestId('YouTubeErrorContent')).toMatchAriaSnapshot(`
645653
- heading "Sorry, this video can only be played on YouTube" [level=1]
@@ -648,6 +656,14 @@ export class DuckPlayerPage {
648656
`);
649657
}
650658

659+
async didShowNoEmbedErrorInSpanish() {
660+
await expect(this.page.getByTestId('YouTubeErrorContent')).toMatchAriaSnapshot(`
661+
- heading "Lo sentimos, este vídeo solo se puede reproducir en YouTube" [level=1]
662+
- paragraph: El creador de este vídeo ha decidido no permitir que se vea en otros sitios.
663+
- paragraph: Sigues pudiendo verlo en YouTube, pero sin la privacidad adicional que ofrece Duck Player.
664+
`);
665+
}
666+
651667
async didShowSignInRequiredError() {
652668
await expect(this.page.getByTestId('YouTubeErrorContent')).toMatchAriaSnapshot(`
653669
- heading "Sorry, YouTube thinks you’re a bot" [level=1]
@@ -658,9 +674,9 @@ export class DuckPlayerPage {
658674

659675
async didShowSignInRequiredErrorInSpanish() {
660676
await expect(this.page.getByTestId('YouTubeErrorContent')).toMatchAriaSnapshot(`
661-
- heading "YouTube no permite que Duck Player cargue este vídeo" [level=1]
662-
- paragraph: YouTube está bloqueando la carga de este vídeo. Si estás usando una VPN, intenta desactivarla y volver a cargar la página.
663-
- paragraph: Si esto no funciona, sigues pudiendo ver este vídeo en YouTube, pero sin la privacidad adicional de Duck Player.
677+
- heading "Lo sentimos, YouTube piensa que eres un bot" [level=1]
678+
- paragraph: Esto puede ocurrir si estás usando una VPN. Intenta desactivar la VPN o cambiar la ubicación del servidor y recarga la página.
679+
- paragraph: Si eso no funciona, tendrás que iniciar sesión y ver el vídeo en YouTube sin la privacidad adicional que ofrece Duck Player.
664680
`);
665681
}
666682
}

special-pages/pages/duckplayer/integration-tests/duckplayer.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@ test.describe('duckplayer custom error', () => {
147147
test.skip(isDesktop(workerInfo));
148148
const duckplayer = DuckPlayerPage.create(page, workerInfo);
149149
await duckplayer.openWithYouTubeError('age-restricted', 'e90eWYPNtJ8', 'es');
150+
await duckplayer.didShowAgeRestrictedErrorInSpanish();
151+
});
152+
test('shows custom error screen, in Spanish, for videos that can’t be embedded', async ({ page }, workerInfo) => {
153+
test.skip(isDesktop(workerInfo));
154+
const duckplayer = DuckPlayerPage.create(page, workerInfo);
155+
await duckplayer.openWithYouTubeError('no-embed', 'e90eWYPNtJ8', 'es');
156+
await duckplayer.didShowNoEmbedErrorInSpanish();
157+
});
158+
test('shows custom error screen, in Spanish, for videos with unknown errors', async ({ page }, workerInfo) => {
159+
test.skip(isDesktop(workerInfo));
160+
const duckplayer = DuckPlayerPage.create(page, workerInfo);
161+
await duckplayer.openWithYouTubeError('unknown', 'e90eWYPNtJ8', 'es');
150162
await duckplayer.didShowGenericErrorInSpanish();
151163
});
152164
});

special-pages/pages/duckplayer/public/locales/bg/duckplayer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,42 @@
3232
"title" : "<b>ГРЕШКА:</b> невалиден идентификатор на видеоклипа",
3333
"note" : "Shown when the page URL doesn't match a known video ID. Note for translators: The <b> tag makes the word 'ERROR:' bold. Depending on the grammar of the target language, you might need to move it so that the correct word is emphasized."
3434
},
35+
"unknownErrorHeading2" : {
36+
"title" : "Duck Player не може да зареди това видео",
37+
"note" : "Message shown when YouTube has blocked playback of a video"
38+
},
39+
"unknownErrorMessage2a" : {
40+
"title" : "Това видео не може да бъде гледано извън YouTube.",
41+
"note" : "Explanation on why the error is happening."
42+
},
43+
"unknownErrorMessage2b" : {
44+
"title" : "Все пак можете да гледате това видео в YouTube, но без допълнителната поверителност на Duck Player.",
45+
"note" : "A message explaining that the blocked video can be watched directly on YouTube."
46+
},
47+
"ageRestrictedErrorHeading2" : {
48+
"title" : "Съжаляваме, но това видео има възрастово ограничение",
49+
"note" : "Message shown when YouTube has blocked playback of a video"
50+
},
51+
"ageRestrictedErrorMessage2a" : {
52+
"title" : "За да гледате видеа с възрастово ограничение, трябва да влезете в YouTube, за да потвърдите възрастта си.",
53+
"note" : "Explanation on why the error is happening."
54+
},
55+
"ageRestrictedErrorMessage2b" : {
56+
"title" : "Все пак можете да гледате това видео, но ще трябва да влезете и да го гледате в YouTube без допълнителната поверителност на Duck Player.",
57+
"note" : "A message explaining that the blocked video can be watched directly on YouTube."
58+
},
59+
"noEmbedErrorHeading2" : {
60+
"title" : "Съжаляваме, но това видео може да се гледа само в YouTube",
61+
"note" : "Message shown when YouTube has blocked playback of a video"
62+
},
63+
"noEmbedErrorMessage2a" : {
64+
"title" : "Създателят на това видео е избрал да не позволява то да бъде гледано на други сайтове.",
65+
"note" : "Explanation on why the error is happening."
66+
},
67+
"noEmbedErrorMessage2b" : {
68+
"title" : "Все пак можете да го гледате в YouTube, но без допълнителната поверителност на Duck Player.",
69+
"note" : "A message explaining that the blocked video can be watched directly on YouTube."
70+
},
3571
"blockedVideoErrorHeading" : {
3672
"title" : "YouTube няма да позволи на Duck Player да зареди това видео",
3773
"note" : "Message shown when YouTube has blocked playback of a video"
@@ -44,6 +80,10 @@
4480
"title" : "Все пак можете да гледате това видео в YouTube, но без допълнителната поверителност на Duck Player.",
4581
"note" : "A message explaining that the blocked video can be watched directly on YouTube."
4682
},
83+
"signInRequiredErrorHeading2" : {
84+
"title" : "Съжаляваме, но YouTube мисли, че сте бот",
85+
"note" : "Message shown when YouTube has blocked playback of a video"
86+
},
4787
"signInRequiredErrorMessage1" : {
4888
"title" : "YouTube блокира зареждането на това видео. Ако използвате VPN, опитайте да го изключите и презаредете тази страница.",
4989
"note" : "Explanation on why the error is happening and a suggestions on how to solve it."
@@ -52,6 +92,14 @@
5292
"title" : "Ако това не свърши работа, можете да гледате това видео в YouTube, но без допълнителната поверителност на Duck Player.",
5393
"note" : "More troubleshooting tips for this specific error"
5494
},
95+
"signInRequiredErrorMessage2a" : {
96+
"title" : "Това може да се случи, ако използвате VPN. Опитайте да изключите VPN или да промените местоположението на сървъра и да презаредите тази страница.",
97+
"note" : "Explanation on why the error is happening and a suggestions on how to solve it."
98+
},
99+
"signInRequiredErrorMessage2b" : {
100+
"title" : "Ако това не проработи, ще трябва да влезете и да гледате това видео в YouTube без допълнителната поверителност на Duck Player.",
101+
"note" : "More troubleshooting tips for this specific error"
102+
},
55103
"tooltipInfo" : {
56104
"title" : "Duck Player осигурява чисто изживяване без персонализирани реклами в YouTube и предотвратява влиянието на вече гледаните видеоклипове върху препоръките на YouTube."
57105
}

special-pages/pages/duckplayer/public/locales/cs/duckplayer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,42 @@
3232
"title" : "<b>CHYBA:</b> Neplatné ID videa",
3333
"note" : "Shown when the page URL doesn't match a known video ID. Note for translators: The <b> tag makes the word 'ERROR:' bold. Depending on the grammar of the target language, you might need to move it so that the correct word is emphasized."
3434
},
35+
"unknownErrorHeading2" : {
36+
"title" : "Duck Player nemůže načíst tohle video",
37+
"note" : "Message shown when YouTube has blocked playback of a video"
38+
},
39+
"unknownErrorMessage2a" : {
40+
"title" : "Na video se nedá dívat mimo YouTube.",
41+
"note" : "Explanation on why the error is happening."
42+
},
43+
"unknownErrorMessage2b" : {
44+
"title" : "Na tohle video se můžeš pořád podívat na YouTube, ale bez ochrany soukromí, jakou nabízí Duck Player.",
45+
"note" : "A message explaining that the blocked video can be watched directly on YouTube."
46+
},
47+
"ageRestrictedErrorHeading2" : {
48+
"title" : "Omlouváme se, ale tohle video je věkově omezené",
49+
"note" : "Message shown when YouTube has blocked playback of a video"
50+
},
51+
"ageRestrictedErrorMessage2a" : {
52+
"title" : "Pokud chceš sledovat videa s věkovým omezením, musíš se přihlásit na YouTube a ověřit svůj věk.",
53+
"note" : "Explanation on why the error is happening."
54+
},
55+
"ageRestrictedErrorMessage2b" : {
56+
"title" : "Na tohle video se i tak můžeš podívat, ale budeš se muset přihlásit a pustit si ho na YouTube bez ochrany soukromí, kterou nabízí Duck Player.",
57+
"note" : "A message explaining that the blocked video can be watched directly on YouTube."
58+
},
59+
"noEmbedErrorHeading2" : {
60+
"title" : "Omlouváme se, ale tohle video se dá přehrát jen na YouTube",
61+
"note" : "Message shown when YouTube has blocked playback of a video"
62+
},
63+
"noEmbedErrorMessage2a" : {
64+
"title" : "Autor tohoto videa se rozhodl nepovolit jeho zobrazení na jiných stránkách.",
65+
"note" : "Explanation on why the error is happening."
66+
},
67+
"noEmbedErrorMessage2b" : {
68+
"title" : "Pořád se na něj můžeš podívat na YouTube, ale bez ochrany soukromí, jakou nabízí Duck Player.",
69+
"note" : "A message explaining that the blocked video can be watched directly on YouTube."
70+
},
3571
"blockedVideoErrorHeading" : {
3672
"title" : "YouTube nedovoluje přehrávači Duck Player načíst tohle video",
3773
"note" : "Message shown when YouTube has blocked playback of a video"
@@ -44,6 +80,10 @@
4480
"title" : "Na tohle video se můžeš pořád podívat na YouTube, ale bez ochrany soukromí, jakou nabízí Duck Player.",
4581
"note" : "A message explaining that the blocked video can be watched directly on YouTube."
4682
},
83+
"signInRequiredErrorHeading2" : {
84+
"title" : "Omlouváme se, ale YouTube si myslí, že jsi robot",
85+
"note" : "Message shown when YouTube has blocked playback of a video"
86+
},
4787
"signInRequiredErrorMessage1" : {
4888
"title" : "YouTube blokuje načítání tohohle videa. Pokud používáš VPN, zkus ji vypnout a stránku znovu načíst.",
4989
"note" : "Explanation on why the error is happening and a suggestions on how to solve it."
@@ -52,6 +92,14 @@
5292
"title" : "Pokud to nefunguje, můžeš se na video podívat na YouTube, ale bez ochrany soukromí, jakou nabízí Duck Player.",
5393
"note" : "More troubleshooting tips for this specific error"
5494
},
95+
"signInRequiredErrorMessage2a" : {
96+
"title" : "To se může stát, pokud používáš VPN. Zkus VPN vypnout nebo změnit umístění serveru a načíst stránku znovu.",
97+
"note" : "Explanation on why the error is happening and a suggestions on how to solve it."
98+
},
99+
"signInRequiredErrorMessage2b" : {
100+
"title" : "Pokud to nezabere, budeš se muset přihlásit a video si na YouTube přehrát bez ochrany soukromí, kterou nabízí Duck Player.",
101+
"note" : "More troubleshooting tips for this specific error"
102+
},
55103
"tooltipInfo" : {
56104
"title" : "Přehrávač Duck Player nabízí sledování v minimalistickém prostředí bez personalizovaných reklam a brání tomu, aby sledovaná videa ovlivňovala tvoje doporučení na YouTube."
57105
}

special-pages/pages/duckplayer/public/locales/da/duckplayer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,42 @@
3232
"title" : "<b>FEJL:</b> Ugyldigt video-ID",
3333
"note" : "Shown when the page URL doesn't match a known video ID. Note for translators: The <b> tag makes the word 'ERROR:' bold. Depending on the grammar of the target language, you might need to move it so that the correct word is emphasized."
3434
},
35+
"unknownErrorHeading2" : {
36+
"title" : "Duck Player kan ikke indlæse denne video",
37+
"note" : "Message shown when YouTube has blocked playback of a video"
38+
},
39+
"unknownErrorMessage2a" : {
40+
"title" : "Denne video kan ikke vises uden for YouTube.",
41+
"note" : "Explanation on why the error is happening."
42+
},
43+
"unknownErrorMessage2b" : {
44+
"title" : "Du kan stadig se denne video på YouTube, men uden den ekstra fortrolighed, som Duck Player giver.",
45+
"note" : "A message explaining that the blocked video can be watched directly on YouTube."
46+
},
47+
"ageRestrictedErrorHeading2" : {
48+
"title" : "Beklager, denne video har aldersbegrænsning",
49+
"note" : "Message shown when YouTube has blocked playback of a video"
50+
},
51+
"ageRestrictedErrorMessage2a" : {
52+
"title" : "For at se aldersbegrænsede videoer skal du logge ind på YouTube for at bekræfte din alder.",
53+
"note" : "Explanation on why the error is happening."
54+
},
55+
"ageRestrictedErrorMessage2b" : {
56+
"title" : "Du kan stadig se denne video, men du skal logge ind og se den på YouTube uden den ekstra fortrolighed, som Duck Player giver.",
57+
"note" : "A message explaining that the blocked video can be watched directly on YouTube."
58+
},
59+
"noEmbedErrorHeading2" : {
60+
"title" : "Beklager, denne video kan kun afspilles på YouTube",
61+
"note" : "Message shown when YouTube has blocked playback of a video"
62+
},
63+
"noEmbedErrorMessage2a" : {
64+
"title" : "Skaberen af denne video har valgt ikke at tillade, at den kan vises på andre hjemmesider.",
65+
"note" : "Explanation on why the error is happening."
66+
},
67+
"noEmbedErrorMessage2b" : {
68+
"title" : "Du kan stadig se den på YouTube, men uden den ekstra fortrolighed, som Duck Player giver.",
69+
"note" : "A message explaining that the blocked video can be watched directly on YouTube."
70+
},
3571
"blockedVideoErrorHeading" : {
3672
"title" : "YouTube vil ikke lade Duck Player indlæse denne video",
3773
"note" : "Message shown when YouTube has blocked playback of a video"
@@ -44,6 +80,10 @@
4480
"title" : "Du kan stadig se denne video på YouTube, men uden den ekstra fortrolighed, som Duck Player giver.",
4581
"note" : "A message explaining that the blocked video can be watched directly on YouTube."
4682
},
83+
"signInRequiredErrorHeading2" : {
84+
"title" : "Beklager, YouTube tror, at du er en bot",
85+
"note" : "Message shown when YouTube has blocked playback of a video"
86+
},
4787
"signInRequiredErrorMessage1" : {
4888
"title" : "YouTube blokerer for, at denne video kan indlæses. Hvis du bruger en VPN, så prøv at slå den fra og genindlæse denne side.",
4989
"note" : "Explanation on why the error is happening and a suggestions on how to solve it."
@@ -52,6 +92,14 @@
5292
"title" : "Hvis dette ikke virker, kan du stadig se denne video på YouTube, men uden den ekstra fortrolighed, som Duck Player giver.",
5393
"note" : "More troubleshooting tips for this specific error"
5494
},
95+
"signInRequiredErrorMessage2a" : {
96+
"title" : "Dette kan ske, hvis du bruger en VPN. Prøv at slå VPN fra eller skifte serverplacering og genindlæse denne side.",
97+
"note" : "Explanation on why the error is happening and a suggestions on how to solve it."
98+
},
99+
"signInRequiredErrorMessage2b" : {
100+
"title" : "Hvis det ikke virker, skal du logge ind og se denne video på YouTube uden den ekstra fortrolighed, som Duck Player giver.",
101+
"note" : "More troubleshooting tips for this specific error"
102+
},
55103
"tooltipInfo" : {
56104
"title" : "Duck Player giver en ren seeroplevelse uden målrettede annoncer og forhindrer, at visningsaktivitet påvirker dine YouTube-anbefalinger."
57105
}

0 commit comments

Comments
 (0)