Skip to content

Commit 2e88402

Browse files
authored
ntp: activity translations (RC1) (#1459)
* ntp: activity translations * ntp: small style fixes for locales * fix middle click * linting * more translations * fixed overflow
1 parent 60ebd00 commit 2e88402

File tree

15 files changed

+697
-49
lines changed

15 files changed

+697
-49
lines changed

special-pages/pages/new-tab/app/activity/components/Activity.examples.js

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,12 @@ import { normalizeData, NormalizedDataContext } from '../NormalizeDataProvider.j
1010
export const activityExamples = {
1111
'activity.empty': {
1212
factory: () => {
13-
return (
14-
<Activity
15-
expansion={'expanded'}
16-
itemCount={0}
17-
trackerCount={0}
18-
toggle={noop('toggle')}
19-
didClick={noop('did click')}
20-
batched={false}
21-
/>
22-
);
13+
return <Activity expansion={'expanded'} itemCount={0} trackerCount={0} toggle={noop('toggle')} batched={false} />;
2314
},
2415
},
2516
'activity.few': {
2617
factory: () => (
27-
<Activity
28-
expansion={'expanded'}
29-
itemCount={10}
30-
trackerCount={20}
31-
toggle={noop('toggle')}
32-
didClick={noop('did click')}
33-
batched={false}
34-
>
18+
<Activity expansion={'expanded'} itemCount={10} trackerCount={20} toggle={noop('toggle')} batched={false}>
3519
<Mock size={3}>
3620
<ActivityBody canBurn={false} visibility={'visible'} />
3721
</Mock>
@@ -40,14 +24,7 @@ export const activityExamples = {
4024
},
4125
'activity.noTrackers': {
4226
factory: () => (
43-
<Activity
44-
expansion={'expanded'}
45-
itemCount={20}
46-
trackerCount={0}
47-
toggle={noop('toggle')}
48-
didClick={noop('did click')}
49-
batched={false}
50-
>
27+
<Activity expansion={'expanded'} itemCount={20} trackerCount={0} toggle={noop('toggle')} batched={false}>
5128
<Mock size={1}>
5229
<ActivityBody canBurn={false} visibility={'visible'} />
5330
</Mock>

special-pages/pages/new-tab/app/activity/components/Activity.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,26 @@ import { ActivityInteractionsContext } from '../../burning/ActivityInteractionsC
3030
* Renders the Activity component with associated heading and body, managing interactivity and state.
3131
*
3232
* @param {Object} props - Object containing all properties required by the Activity component.
33-
* @param {(evt: MouseEvent) => void} props.didClick - Callback function triggered when the root element is clicked.
3433
* @param {Expansion} props.expansion - String indicating the expansion state of the activity, such as 'expanded' or 'collapsed'.
3534
* @param {() => void} props.toggle - Callback function to handle the expansion/collapse action.
3635
* @param {number} props.trackerCount - Object representing the tracker count for the activity.
3736
* @param {number} props.itemCount - Object representing the count of items in the activity.
3837
* @param {boolean} props.batched - Boolean indicating whether the activity uses batched loading.
3938
* @param {import("preact").ComponentChild} [props.children]
4039
*/
41-
export function Activity({ didClick, expansion, toggle, trackerCount, itemCount, batched, children }) {
40+
export function Activity({ expansion, toggle, trackerCount, itemCount, batched, children }) {
4241
// see: https://www.w3.org/WAI/ARIA/apg/patterns/accordion/examples/accordion/
4342
const expanded = expansion === 'expanded';
4443
const WIDGET_ID = useId();
4544
const TOGGLE_ID = useId();
45+
const { didClick } = useContext(ActivityInteractionsContext);
46+
47+
const ref = useRef(null);
48+
useOnMiddleClick(ref, didClick);
49+
4650
return (
4751
<Fragment>
48-
<div class={styles.root} onClick={didClick}>
52+
<div class={styles.root} onClick={didClick} ref={ref}>
4953
<ActivityHeading
5054
trackerCount={trackerCount}
5155
itemCount={itemCount}
@@ -240,10 +244,6 @@ export function ActivityConfigured({ expansion, toggle, children }) {
240244
const batched = useBatchedActivityApi();
241245

242246
const { activity } = useContext(NormalizedDataContext);
243-
const { didClick } = useContext(ActivityInteractionsContext);
244-
245-
const ref = useRef(/** @type {HTMLUListElement|null} */ (null));
246-
useOnMiddleClick(ref, didClick);
247247

248248
const count = useComputed(() => {
249249
return activity.value.totalTrackers;
@@ -254,14 +254,7 @@ export function ActivityConfigured({ expansion, toggle, children }) {
254254
});
255255

256256
return (
257-
<Activity
258-
batched={batched}
259-
itemCount={itemCount.value}
260-
trackerCount={count.value}
261-
expansion={expansion}
262-
toggle={toggle}
263-
didClick={didClick}
264-
>
257+
<Activity batched={batched} itemCount={itemCount.value} trackerCount={count.value} expansion={expansion} toggle={toggle}>
265258
{children}
266259
</Activity>
267260
);

special-pages/pages/new-tab/app/activity/integration-tests/activity.page.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export class ActivityPage {
193193
await page.getByText('example.com').click();
194194
await page.getByText('example.com').click({ modifiers: ['Meta'] });
195195
await page.getByText('example.com').click({ modifiers: ['Shift'] });
196+
await page.getByText('example.com').click({ button: 'middle' });
196197
await this._opensMainLink();
197198
}
198199
async _opensMainLink() {
@@ -213,6 +214,11 @@ export class ActivityPage {
213214
url,
214215
target: 'new-window',
215216
});
217+
218+
expect(calls[3].payload.params).toStrictEqual({
219+
url,
220+
target: 'new-window',
221+
});
216222
}
217223

218224
async opensLinkFromHistory() {

special-pages/pages/new-tab/app/customizer/components/BrowserThemeSection.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function BrowserThemeSection(props) {
3131
>
3232
<span class="sr-only">{t('customizer_browser_theme_label', { type: 'light' })}</span>
3333
</button>
34-
{t('customizer_browser_theme_light')}
34+
<span>{t('customizer_browser_theme_light')}</span>
3535
</li>
3636
<li class={styles.themeItem}>
3737
<button
@@ -44,7 +44,7 @@ export function BrowserThemeSection(props) {
4444
>
4545
<span class="sr-only">{t('customizer_browser_theme_label', { type: 'dark' })}</span>
4646
</button>
47-
{t('customizer_browser_theme_dark')}
47+
<span>{t('customizer_browser_theme_dark')}</span>
4848
</li>
4949
<li class={styles.themeItem}>
5050
<button
@@ -57,7 +57,7 @@ export function BrowserThemeSection(props) {
5757
>
5858
<span class="sr-only">{t('customizer_browser_theme_label', { type: 'system' })}</span>
5959
</button>
60-
{t('customizer_browser_theme_system')}
60+
<span>{t('customizer_browser_theme_system')}</span>
6161
</li>
6262
</ul>
6363
);

special-pages/pages/new-tab/app/customizer/components/BrowserThemeSection.module.css

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@
55
--chip-size-half: calc(var(--chip-size) / 2);
66
}
77
.themeItem {
8-
display: grid;
9-
justify-items: center;
10-
grid-row-gap: 4px;
8+
width: 42px;
9+
10+
span {
11+
margin-top: 6px;
12+
text-align: center;
13+
overflow: hidden;
14+
text-overflow: ellipsis;
15+
display: block;
16+
}
1117
}
1218
.themeButton {
1319
display: block;

special-pages/pages/new-tab/app/customizer/components/CustomizerDrawerInner.module.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
display: flex;
1919
justify-content: space-between;
2020
align-items: center;
21+
gap: 6px;
22+
23+
> * {
24+
overflow: hidden;
25+
}
2126
}
2227

2328
.internal {
@@ -30,6 +35,7 @@
3035
width: 24px;
3136
height: 24px;
3237
position: relative;
38+
flex-shrink: 0;
3339

3440
color: var(--color-black-at-84);
3541
background-color: var(--color-black-at-9);
@@ -91,7 +97,6 @@
9197
.bgListItem {
9298
display: grid;
9399
grid-row-gap: 4px;
94-
white-space: nowrap;
95100
position: relative;
96101

97102
&:hover {

special-pages/pages/new-tab/app/favorites/integration-tests/favorites.page.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ export class FavoritesPage {
2626

2727
async opensInNewWindow() {
2828
await this.nthFavorite(0).click({ modifiers: ['Shift'] });
29-
const calls = await this.ntp.mocks.waitForCallCount({ method: 'favorites_open', count: 1 });
29+
await this.nthFavorite(0).click({ button: 'middle' });
30+
const calls = await this.ntp.mocks.waitForCallCount({ method: 'favorites_open', count: 2 });
3031
expect(calls[0].payload.params).toStrictEqual({ id: 'id-many-1', url: 'https://example.com/?id=id-many-1', target: 'new-window' });
32+
expect(calls[1].payload.params).toStrictEqual({ id: 'id-many-1', url: 'https://example.com/?id=id-many-1', target: 'new-window' });
3133
}
3234

3335
async opensInSameTab() {

special-pages/pages/new-tab/public/locales/de/new-tab.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,53 @@
271271
"customizer_image_delete" : {
272272
"title" : "Bild {number} löschen",
273273
"note" : "Label text on a button that deletes an image. {number} will be replaced with a numeric reference of 1-8, eg: 'Delete image 1'"
274+
},
275+
"activity_noRecent_title" : {
276+
"title" : "Keine kürzliche Browsing-Aktivität",
277+
"note" : "Placeholder to indicate that no browsing activity was seen in the last 7 days"
278+
},
279+
"activity_noRecent_subtitle" : {
280+
"title" : "Zuletzt besuchte Seiten werden hier angezeigt. Browse weiter, um zu sehen, wie viele Tracker wir blockieren.",
281+
"note" : "Shown in the place a list of browsing history entries will be displayed."
282+
},
283+
"activity_no_trackers" : {
284+
"title" : "Keine Tracker gefunden",
285+
"note" : "Placeholder message indicating that no trackers are detected"
286+
},
287+
"activity_no_trackers_blocked" : {
288+
"title" : "Keine Tracker blockiert",
289+
"note" : "Placeholder message indicating that no trackers are blocked"
290+
},
291+
"activity_countBlockedPlural" : {
292+
"title" : "<b>{count}</b> Tracking-Versuche blockiert",
293+
"note" : "The main headline indicating that more than 1 attempt has been blocked. Eg: '2 tracking attempts blocked'"
294+
},
295+
"activity_favoriteAdd" : {
296+
"title" : "{domain} zu Favoriten hinzufügen",
297+
"note" : "Button label, allows the user to add the specified domain to their favorites"
298+
},
299+
"activity_favoriteRemove" : {
300+
"title" : "{domain} aus Favoriten entfernen",
301+
"note" : "Button label, allows the user to remove the specified domain from their favorites"
302+
},
303+
"activity_itemRemove" : {
304+
"title" : "{domain} aus dem Verlauf entfernen",
305+
"note" : "Button label for clearing browsing history for a given domain."
306+
},
307+
"activity_burn" : {
308+
"title" : "Browserverlauf und Daten für {domain} löschen",
309+
"note" : "Button label for clearing browsing history and data exclusively for the specified domain"
310+
},
311+
"activity_menuTitle" : {
312+
"title" : "Aktuelle Aktivitäten",
313+
"note" : "Used as a label in a customization menu"
314+
},
315+
"activity_show_more_history" : {
316+
"title" : "{count} weitere anzeigen",
317+
"note" : "Button label that expands the list of browsing history with the specified count of additional items. Example: 'Show 5 more'"
318+
},
319+
"activity_show_less_history" : {
320+
"title" : "Zusätzliches ausblenden",
321+
"note" : "Button label that hides the expanded browsing history items."
274322
}
275323
}

special-pages/pages/new-tab/public/locales/es/new-tab.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,53 @@
271271
"customizer_image_delete" : {
272272
"title" : "Eliminar imagen {number}",
273273
"note" : "Label text on a button that deletes an image. {number} will be replaced with a numeric reference of 1-8, eg: 'Delete image 1'"
274+
},
275+
"activity_noRecent_title" : {
276+
"title" : "No hay actividad de navegación reciente",
277+
"note" : "Placeholder to indicate that no browsing activity was seen in the last 7 days"
278+
},
279+
"activity_noRecent_subtitle" : {
280+
"title" : "Los sitios visitados recientemente aparecen aquí. Sigue navegando para ver cuántos rastreadores hemos bloqueado.",
281+
"note" : "Shown in the place a list of browsing history entries will be displayed."
282+
},
283+
"activity_no_trackers" : {
284+
"title" : "No se han encontrado rastreadores",
285+
"note" : "Placeholder message indicating that no trackers are detected"
286+
},
287+
"activity_no_trackers_blocked" : {
288+
"title" : "No se han bloqueado rastreadores",
289+
"note" : "Placeholder message indicating that no trackers are blocked"
290+
},
291+
"activity_countBlockedPlural" : {
292+
"title" : "<b>{count}</b> intentos de rastreo bloqueados",
293+
"note" : "The main headline indicating that more than 1 attempt has been blocked. Eg: '2 tracking attempts blocked'"
294+
},
295+
"activity_favoriteAdd" : {
296+
"title" : "Añadir {domain} a favoritos",
297+
"note" : "Button label, allows the user to add the specified domain to their favorites"
298+
},
299+
"activity_favoriteRemove" : {
300+
"title" : "Eliminar {domain} de favoritos",
301+
"note" : "Button label, allows the user to remove the specified domain from their favorites"
302+
},
303+
"activity_itemRemove" : {
304+
"title" : "Eliminar {domain} del historial",
305+
"note" : "Button label for clearing browsing history for a given domain."
306+
},
307+
"activity_burn" : {
308+
"title" : "Borra el historial de navegación y los datos de {domain}",
309+
"note" : "Button label for clearing browsing history and data exclusively for the specified domain"
310+
},
311+
"activity_menuTitle" : {
312+
"title" : "Actividad reciente",
313+
"note" : "Used as a label in a customization menu"
314+
},
315+
"activity_show_more_history" : {
316+
"title" : "Mostrar {count} más",
317+
"note" : "Button label that expands the list of browsing history with the specified count of additional items. Example: 'Show 5 more'"
318+
},
319+
"activity_show_less_history" : {
320+
"title" : "Ocultar adicional",
321+
"note" : "Button label that hides the expanded browsing history items."
274322
}
275323
}

special-pages/pages/new-tab/public/locales/fr/new-tab.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,53 @@
271271
"customizer_image_delete" : {
272272
"title" : "Supprimer l'image {number}",
273273
"note" : "Label text on a button that deletes an image. {number} will be replaced with a numeric reference of 1-8, eg: 'Delete image 1'"
274+
},
275+
"activity_noRecent_title" : {
276+
"title" : "Aucune activité de navigation récente",
277+
"note" : "Placeholder to indicate that no browsing activity was seen in the last 7 days"
278+
},
279+
"activity_noRecent_subtitle" : {
280+
"title" : "Les sites récemment visités apparaîtront ici. Continuez à naviguer pour voir combien de traqueurs nous bloquons.",
281+
"note" : "Shown in the place a list of browsing history entries will be displayed."
282+
},
283+
"activity_no_trackers" : {
284+
"title" : "Aucun traqueur trouvé",
285+
"note" : "Placeholder message indicating that no trackers are detected"
286+
},
287+
"activity_no_trackers_blocked" : {
288+
"title" : "Aucun traqueur bloqué",
289+
"note" : "Placeholder message indicating that no trackers are blocked"
290+
},
291+
"activity_countBlockedPlural" : {
292+
"title" : "<b>{count}</b> tentative(s) de pistage bloquée(s)",
293+
"note" : "The main headline indicating that more than 1 attempt has been blocked. Eg: '2 tracking attempts blocked'"
294+
},
295+
"activity_favoriteAdd" : {
296+
"title" : "Ajouter {domain} aux favoris",
297+
"note" : "Button label, allows the user to add the specified domain to their favorites"
298+
},
299+
"activity_favoriteRemove" : {
300+
"title" : "Supprimer {domain} des favoris",
301+
"note" : "Button label, allows the user to remove the specified domain from their favorites"
302+
},
303+
"activity_itemRemove" : {
304+
"title" : "Supprimer {domain} de l’historique",
305+
"note" : "Button label for clearing browsing history for a given domain."
306+
},
307+
"activity_burn" : {
308+
"title" : "Effacer l'historique de navigation et les données pour {domain}",
309+
"note" : "Button label for clearing browsing history and data exclusively for the specified domain"
310+
},
311+
"activity_menuTitle" : {
312+
"title" : "Activité récente",
313+
"note" : "Used as a label in a customization menu"
314+
},
315+
"activity_show_more_history" : {
316+
"title" : "Afficher {count} de plus",
317+
"note" : "Button label that expands the list of browsing history with the specified count of additional items. Example: 'Show 5 more'"
318+
},
319+
"activity_show_less_history" : {
320+
"title" : "Masquer les éléments supplémentaires",
321+
"note" : "Button label that hides the expanded browsing history items."
274322
}
275323
}

0 commit comments

Comments
 (0)