Skip to content

Commit 274ad7d

Browse files
dominicbachmanngeromegrignon
authored andcommitted
feat: add custom ids and ci/cd script for validating that all translations are set
1 parent d03db66 commit 274ad7d

19 files changed

+183
-153
lines changed

.husky/commit-msg

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
3-
41
npx commitlint --edit $1

.husky/pre-commit

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
41
npx lint-staged
2+
npm run i18n:validate-no-empty-translations

messages.json

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11
{
22
"locale": "en",
33
"translations": {
4-
"5729418620241283277": "Events",
5-
"4282290715877032507": "Organizers",
6-
"5481284030283031915": "Website",
7-
"8585369201408386550": " Join the community ",
8-
"635264773021131084": " Starting from ",
9-
"7097963028377891250": " To be announced ",
10-
"457763919401259967": " Registration ",
11-
"5891064527381218201": "Free",
12-
"8291262399353359697": "Attendees",
13-
"5260501588919384967": " Register now ",
14-
"6364272713313334628": " No registration available ",
15-
"926352149584380702": "Organized by",
16-
"4862119345478890729": " Listen Now ",
17-
"383604207727627418": "Try adjusting your search terms",
18-
"6380110438893831255": "or browse all events above",
19-
"6257229111292962180": "The Angular community hub for events, communities, and podcasts",
20-
"6910865064463105075": "Communities",
21-
"1984987229407697795": "Podcasts",
22-
"3676011873566441889": "Curated list of Angular communities",
23-
"1229359301315184889": "Curated list of Angular Events",
24-
"3776293039808729401": "No events found",
25-
"4118966711789506787": "We could not find any events matching your search criteria. Try different keywords or browse all available events.",
26-
"8228704013073542414": "No upcoming events",
27-
"5181869256727726277": "There are currently no upcoming Angular events scheduled. New events are added regularly, so please check back soon!",
28-
"2104481506343485854": "Curated list of Angular Communities, Events, Podcasts, and Call for Papers.",
29-
"8162118643101139148": "Developers interested in Angular and related technologies.",
30-
"6829527508389756715": "Angular Events",
31-
"8870711330013548872": "Online",
32-
"6578397717654172779": "Page Not Found",
33-
"1659745110459296080": "Go Back Home",
34-
"5674307105789988119": "Curated list of Angular Talks"
4+
"community-card.events": "Events",
5+
"community-card.organizers": "Organizers",
6+
"community-card.website": "Website",
7+
"community-card.join": " Join the community ",
8+
"event-card.starting-from": " Starting from ",
9+
"event-card.tba": " To be announced ",
10+
"event-card.registration": " Registration ",
11+
"event-card.fee": "Free",
12+
"event-card.attendees": "Attendees",
13+
"event-card.register-now": " Register now ",
14+
"event-card.no-registration": " No registration available ",
15+
"event-card.organized-by": "Organized by",
16+
"podcast-card.listen-now": " Listen Now ",
17+
"message.empty-recommendation": "Try adjusting your search terms",
18+
"message.browse-all": "or browse all events above",
19+
"navigation.slogan": "The Angular community hub for events, communities, and podcasts",
20+
"navigation.events": "Events",
21+
"navigation.communities": "Communities",
22+
"navigation.podcasts": "Podcasts",
23+
"communities-page.meta-description": "Curated list of Angular communities",
24+
"events-page.meta-description": "Curated list of Angular Events",
25+
"events-page.og-title": "Curated list of Angular Events",
26+
"events-page.empty-search-message-title": "No events found",
27+
"events-page.empty-search-message-description": "We could not find any events matching your search criteria. Try different keywords or browse all available events.",
28+
"events-page.empty-events-message-title": "No upcoming events",
29+
"events-page.empty-events-message-description": "There are currently no upcoming Angular events scheduled. New events are added regularly, so please check back soon!",
30+
"events-page.json-ld.description": "Curated list of Angular Communities, Events, Podcasts, and Call for Papers.",
31+
"events-page.json-ld.audience-description": "Developers interested in Angular and related technologies.",
32+
"events-page.json-ld.main-entity.name": "Angular Events",
33+
"events-page.json-ld.main-entity.item.description": "Developers interested in Angular and related technologies.",
34+
"events-page.json-ld.main-entity.item.online": "Online",
35+
"not-found-page.not-found": "Page Not Found",
36+
"not-found-page.go-home": "Go Back Home",
37+
"podcasts-page.meta-description": "Curated list of Angular Talks"
3538
}
3639
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
"version": "0.0.0",
44
"license": "MIT",
55
"scripts": {
6+
"prepare": "husky",
67
"ng": "ng",
78
"start": "ng serve",
89
"build": "ng build",
910
"watch": "ng build --watch --configuration development",
1011
"test": "ng test",
1112
"serve:ssr:angular-hub": "node dist/angular-hub/server/server.mjs",
1213
"i18n:extract": "ng extract-i18n --format json",
13-
"i18n:merge-translations": "node ./scripts/merge-translations.js"
14+
"i18n:merge-translations": "node scripts/merge-translations.mjs",
15+
"i18n:validate-no-empty-translations": "npm run i18n:extract && npm run i18n:merge-translations && node scripts/validate-no-empty-translations.mjs"
1416
},
1517
"private": true,
1618
"prettier": {

scripts/merge-translations.js renamed to scripts/merge-translations.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { readFile, writeFile } from "node:fs/promises";
2-
import config from '../angular.json' with { type: 'json' };
32
import messagesFile from '../messages.json' with { type: 'json' };
3+
import {getLocaleFilePaths} from "./translations/get-locale-files.mjs";
44

5-
const localesFilePaths = Object.values(config.projects["angular-hub"].i18n.locales).map((locale) => locale.translation);
5+
const localesFilePaths = getLocaleFilePaths();
66

77
const messages = Object.entries(messagesFile.translations);
88

@@ -14,7 +14,7 @@ const newLocales = await Promise.all(localesFilePaths.map(async (localeFilePath)
1414
const updatedTranslations = messages.reduce((acc, [key, value]) => {
1515
return {
1616
...acc,
17-
[key]: key in localeFileData.translations ? localeFileData.translations[key] : value
17+
[key]: key in localeFileData.translations ? localeFileData.translations[key] : ""
1818
}
1919
}, {});
2020

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import config from "../../angular.json" with { type: 'json' };
2+
3+
export const getLocaleFilePaths = () => Object.values(config.projects["angular-hub"].i18n.locales).map((locale) => locale.translation);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {getLocaleFilePaths} from "./translations/get-locale-files.mjs";
2+
import {readFile} from "node:fs/promises";
3+
4+
const localesFilePaths = getLocaleFilePaths();
5+
6+
const missingKeysPerLocale = await Promise.all(localesFilePaths.map(async (localeFilePath) => {
7+
const localeFile = await readFile(localeFilePath, { encoding: 'utf-8' });
8+
9+
return {
10+
localeFilePath,
11+
missingTranslations: Object.entries(JSON.parse(localeFile).translations).filter(([_key, value]) => value === "").map(([key]) => key),
12+
}
13+
}));
14+
15+
const hasMissingTranslations = missingKeysPerLocale.some((file) => file.missingTranslations.length);
16+
17+
if (hasMissingTranslations) {
18+
console.error('Missing translations', missingKeysPerLocale);
19+
process.exitCode = 1;
20+
}else {
21+
process.exit(0);
22+
}

src/app/components/cards/community-card.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { Community } from '../../../models/community.model';
3232
class="text-sm hover:underline flex items-center gap-2"
3333
>
3434
<i class="pi pi-calendar text-2xl text-[#BF25B9]"></i>
35-
<span i18n>Events</span>
35+
<span i18n="@@community-card.events">Events</span>
3636
</a>
3737
</li>
3838
}
@@ -44,7 +44,7 @@ import { Community } from '../../../models/community.model';
4444
class="text-sm hover:underline flex items-center gap-2"
4545
>
4646
<i class="pi pi-users text-2xl text-[#0077B5]"></i>
47-
<span i18n>Organizers</span>
47+
<span i18n="@@community-card.organizers">Organizers</span>
4848
</a>
4949
</li>
5050
}
@@ -56,7 +56,7 @@ import { Community } from '../../../models/community.model';
5656
class="text-sm hover:underline flex items-center gap-2"
5757
>
5858
<i class="pi pi-globe text-2xl text-[#0077B5]"></i>
59-
<span i18n>Website</span>
59+
<span i18n="@@community-card.website">Website</span>
6060
</a>
6161
</li>
6262
}
@@ -121,7 +121,7 @@ import { Community } from '../../../models/community.model';
121121
[href]="community().eventsUrl"
122122
target="_blank"
123123
class="w-full flex items-center justify-center text-sm bg-[#26A0D9] text-white p-2 rounded-lg"
124-
i18n
124+
i18n="@@community-card.join"
125125
>
126126
Join the community
127127
</a>

src/app/components/cards/event-card.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { CommunityEvent } from '../../../models/community-event.model';
4545
>
4646
@if (!event().isFree) {
4747
<div class="flex flex-col">
48-
<div class="text-sm text-gray-500 dark:text-gray-200" i18n>
48+
<div class="text-sm text-gray-500 dark:text-gray-200" i18n="@@event-card.starting-from">
4949
Starting from
5050
</div>
5151
<div class="font-bold text-[#26A0D9] flex items-end gap-1">
@@ -55,23 +55,23 @@ import { CommunityEvent } from '../../../models/community-event.model';
5555
</span>
5656
<span class="text-2xl"> {{ event().startingPrice }}* </span>
5757
} @else {
58-
<ng-container i18n>
58+
<ng-container i18n="@@event-card.tba">
5959
To be announced
6060
</ng-container>
6161
}
6262
</div>
6363
</div>
6464
} @else {
6565
<div class="flex flex-col">
66-
<div class="text-sm text-gray-500 dark:text-gray-200" i18n>
66+
<div class="text-sm text-gray-500 dark:text-gray-200" i18n="@@event-card.registration">
6767
Registration
6868
</div>
69-
<div class="font-bold text-2xl text-[#26A0D9]" i18n>Free</div>
69+
<div class="font-bold text-2xl text-[#26A0D9]" i18n="@@event-card.fee">Free</div>
7070
</div>
7171
}
7272
@if (event().attendeesCount) {
7373
<div class="flex flex-col items-center">
74-
<div class="text-sm text-gray-500" i18n>Attendees</div>
74+
<div class="text-sm text-gray-500" i18n="@@event-card.attendees">Attendees</div>
7575
<div class="text-sm font-bold">{{ event().attendeesCount }}</div>
7676
</div>
7777
}
@@ -81,14 +81,14 @@ import { CommunityEvent } from '../../../models/community-event.model';
8181
[href]="event().url"
8282
target="_blank"
8383
class="w-full flex items-center justify-center text-sm bg-[#26A0D9] text-white p-2 rounded-lg"
84-
i18n
84+
i18n="@@event-card.register-now"
8585
>
8686
Register now
8787
</a>
8888
} @else {
8989
<div
9090
class="w-full flex items-center justify-center text-sm bg-gray-200 p-2 rounded-lg dark:text-gray-900"
91-
i18n
91+
i18n="@@event-card.no-registration"
9292
>
9393
No registration available
9494
</div>
@@ -98,7 +98,7 @@ import { CommunityEvent } from '../../../models/community-event.model';
9898
target="_blank"
9999
class="flex items-center gap-2 text-xs hover:underline hover:text-[#26A0D9]"
100100
>
101-
<span i18n>Organized by</span>
101+
<span i18n="@@event-card.organized-by">Organized by</span>
102102
<div
103103
class="w-6 h-6 rounded-full p-1 bg-gray-100 flex items-center justify-center"
104104
>

src/app/components/cards/podcast-card.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import { Podcast } from '../../../models/podcast.model';
4848
<i
4949
class="pi pi-play-circle text-purple-600 text-2xl dark:text-purple-300"
5050
></i>
51-
<span class="font-medium text-purple-600 dark:text-purple-300" i18n>
51+
<span class="font-medium text-purple-600 dark:text-purple-300" i18n="@@podcast-card.listen-now">
5252
Listen Now
5353
</span>
5454
</div>

0 commit comments

Comments
 (0)