Skip to content

Commit 085e780

Browse files
authored
Merge pull request #1000 from Divyansh013/main
[GSOC 2025]: Translation Tracker Github Action
2 parents 002b8fa + fb9793f commit 085e780

File tree

12 files changed

+436
-187
lines changed

12 files changed

+436
-187
lines changed

.github/actions/translation-tracker/index.js

Lines changed: 193 additions & 182 deletions
Large diffs are not rendered by default.

.github/actions/translation-tracker/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"dependencies": {
2323
"@actions/core": "^1.10.0",
2424
"@actions/github": "^5.1.1",
25-
"@octokit/rest": "^19.0.5"
25+
"@octokit/rest": "^19.0.5",
26+
"js-yaml": "^4.1.0"
2627
}
27-
}
28+
}

.github/stewards.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
stewards:
2+
- name: Divyansh013
3+
github: Divyansh013
4+
languages:
5+
- hi
6+
- name: takshittt
7+
github: takshittt
8+
languages:
9+
- hi
10+
- name: hana-cho
11+
github: hana-cho
12+
languages:
13+
- ko
14+
- name: limzykenneth
15+
github: limzykenneth
16+
languages:
17+
- zh-Hans
18+
- name: lirenjie95
19+
github: lirenjie95
20+
languages:
21+
- zh-Hans
22+

.github/workflows/translation-sync.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,23 @@ name: Translation Sync Tracker
22

33
on:
44
push:
5-
branches: [staging]
5+
branches: [main]
66
paths:
77
- 'src/content/examples/en/**'
8+
- 'src/content/reference/en/**'
9+
- 'src/content/tutorials/en/**'
10+
- 'src/content/text-detail/en/**'
11+
- 'src/content/events/en/**'
12+
- 'src/content/libraries/en/**'
13+
pull_request:
14+
branches: [main]
15+
paths:
16+
- 'src/content/examples/en/**'
17+
- 'src/content/reference/en/**'
18+
- 'src/content/tutorials/en/**'
19+
- 'src/content/text-detail/en/**'
20+
- 'src/content/events/en/**'
21+
- 'src/content/libraries/en/**'
822
workflow_dispatch:
923

1024
jobs:
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
interface Props {
3+
englishUrl?: string;
4+
contributeUrl?: string;
5+
title?: string;
6+
message?: string;
7+
locale?: string;
8+
}
9+
10+
const {
11+
englishUrl = '/en',
12+
contributeUrl = 'https://github.com/processing/p5.js-website/tree/main?tab=readme-ov-file#content-changes',
13+
title,
14+
message,
15+
locale = 'en',
16+
} = Astro.props as Props;
17+
18+
const copyByLocale: Record<string, { title: string; message: string; viewEnglish: string; contribute: string; }> = {
19+
'hi': {
20+
title: 'यह अनुवाद पुराना हो सकता है',
21+
message: 'यह पृष्ठ अंग्रेज़ी संस्करण की तुलना में अद्यतन नहीं है।',
22+
viewEnglish: 'अंग्रेज़ी संस्करण देखें',
23+
contribute: 'अनुवाद में योगदान दें',
24+
},
25+
'es': {
26+
title: 'Esta traducción podría estar desactualizada',
27+
message: 'Esta página no está actualizada en comparación con la versión en inglés.',
28+
viewEnglish: 'Ver versión en inglés',
29+
contribute: 'Contribuir a la traducción',
30+
},
31+
'ko': {
32+
title: '이 번역은 오래되었을 수 있습니다',
33+
message: '이 페이지는 영어 버전과 비교하여 최신 상태가 아닙니다.',
34+
viewEnglish: '영어 페이지 보기',
35+
contribute: '번역에 기여하기',
36+
},
37+
'zh-Hans': {
38+
title: '此翻译可能已过期',
39+
message: '与英文版本相比,此页面不是最新的。',
40+
viewEnglish: '查看英文页面',
41+
contribute: '参与翻译',
42+
},
43+
};
44+
45+
const fallback = {
46+
title: 'This translation might be outdated',
47+
message: 'This page is not updated compared to the English version.',
48+
viewEnglish: 'View English page',
49+
contribute: 'Contribute to translation',
50+
};
51+
52+
const copy = copyByLocale[locale] || fallback;
53+
const resolvedTitle = title ?? copy.title;
54+
const resolvedMessage = message ?? copy.message;
55+
---
56+
57+
<section class="outdated-banner" role="status" aria-live="polite">
58+
<div class="icon" aria-hidden="true">⚠️</div>
59+
<div class="content">
60+
<div class="title">{resolvedTitle}</div>
61+
<p class="desc">
62+
{resolvedMessage}
63+
<a class="link" href={englishUrl}>{copy.viewEnglish}</a>
64+
·
65+
<a class="link" href={contributeUrl} target="_blank" rel="noopener noreferrer">{copy.contribute}</a>
66+
</p>
67+
</div>
68+
69+
<style>
70+
.outdated-banner {
71+
display: flex;
72+
align-items: flex-start;
73+
gap: 16px;
74+
padding: 16px 20px;
75+
border-radius: 12px;
76+
background: #d8f532;
77+
color: #000;
78+
margin: 16px 0 24px;
79+
}
80+
.icon { font-size: 22px; line-height: 1; margin-top: 2px; }
81+
.content { flex: 1; }
82+
.title { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
83+
.desc { margin: 0; font-size: 14px; }
84+
.link { color: inherit; font-weight: 700; text-underline-offset: 2px; }
85+
.link:hover { text-decoration: underline; }
86+
</style>
87+
</section>
88+

src/content/examples/en/01_Shapes_And_Color/00_Shape_Primitives/description.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ primitive functions
1717
<a href="https://p5js.org/reference/p5/arc" target="_blank">arc()</a>,
1818
<a href="https://p5js.org/reference/p5/line" target="_blank">line()</a>,
1919
<a href="https://p5js.org/reference/p5/triangle" target="_blank">triangle()</a>,
20-
and <a href="https://p5js.org/reference/p5/quad" target="_blank">quad()</a>.
20+
and <a href="https://p5js.org/reference/p5/quad" target="_blank">quad()</a>.

src/layouts/EventLayout.astro

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import RelatedItems from "@components/RelatedItems/index.astro";
88
import { setJumpToState } from "../globals/state";
99
import { getCurrentLocale, getUiTranslator } from "../i18n/utils";
1010
import { getRelatedEntriesinCollection } from "../pages/_utils";
11+
import OutdatedTranslationBanner from "@components/OutdatedTranslationBanner/index.astro";
12+
import { checkTranslationBanner } from "../utils/translationBanner";
1113
1214
interface Props {
1315
entry: CollectionEntry<"events">;
@@ -31,9 +33,17 @@ const relatedEvents =
3133
? await getRelatedEntriesinCollection(
3234
"events",
3335
currentLocale,
34-
entry.data.relatedPastEvents.map((r) => r.slug)
36+
entry.data.relatedPastEvents.map((r: any) => r.slug)
3537
)
3638
: [];
39+
40+
const { showBanner, englishUrl } = checkTranslationBanner(
41+
'events',
42+
entry.id,
43+
currentLocale,
44+
Astro.url.pathname,
45+
Astro.url.origin
46+
);
3747
---
3848

3949
<Head
@@ -43,6 +53,7 @@ const relatedEvents =
4353
/>
4454

4555
<BaseLayout title={title} subtitle={dayString} variant="item" topic="community">
56+
{showBanner && <OutdatedTranslationBanner englishUrl={englishUrl} locale={currentLocale} />}
4657
{
4758
entry.data.featuredImage && entry.data.featuredImageAlt && (
4859
<Image

src/layouts/ExampleLayout.astro

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
import BaseLayout from "./BaseLayout.astro";
1111
import EditableSketch from "@components/EditableSketch/index.astro";
1212
import RelatedItems from "@components/RelatedItems/index.astro";
13+
import OutdatedTranslationBanner from "@components/OutdatedTranslationBanner/index.astro";
14+
import { checkTranslationBanner } from "../utils/translationBanner";
1315
1416
interface Props {
1517
example: CollectionEntry<"examples">;
@@ -42,6 +44,14 @@ const relatedReferences =
4244
: [];
4345
4446
const { Content } = await example.render();
47+
48+
const { showBanner, englishUrl } = checkTranslationBanner(
49+
'examples',
50+
example.id,
51+
currentLocale,
52+
Astro.url.pathname,
53+
Astro.url.origin
54+
);
4555
---
4656

4757
<Head
@@ -59,6 +69,7 @@ const { Content } = await example.render();
5969
topic="examples"
6070
className="example"
6171
>
72+
{showBanner && <OutdatedTranslationBanner englishUrl={englishUrl} locale={currentLocale} />}
6273
<div class="mt-xl mb-4xl lg:mb-3xl max-w-[770px]">
6374
<div class="rendered-markdown">
6475
<Content />

src/layouts/ReferenceItemLayout.astro

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { setJumpToState } from "../globals/state";
2121
import { p5Version } from "../globals/p5-version";
2222
import flask from "@src/content/ui/images/icons/flask.svg?raw";
2323
import warning from "@src/content/ui/images/icons/warning.svg?raw";
24+
import OutdatedTranslationBanner from "@components/OutdatedTranslationBanner/index.astro";
25+
import { checkTranslationBanner } from "../utils/translationBanner";
2426
2527
const { entry, relatedEntries } = Astro.props;
2628
const currentLocale = getCurrentLocale(Astro.url.pathname);
@@ -81,6 +83,13 @@ const descriptionParts = description.split(
8183
/(<pre><code class="language-js example">[\s\S]+?<\/code><\/pre>)/gm
8284
);
8385
86+
const { showBanner, englishUrl } = checkTranslationBanner(
87+
'reference',
88+
entry.id,
89+
currentLocale,
90+
Astro.url.pathname,
91+
Astro.url.origin
92+
);
8493
---
8594

8695
<Head title={entry.data.title} locale={currentLocale} />
@@ -93,6 +102,7 @@ const descriptionParts = description.split(
93102
topic="reference"
94103
className="reference-item"
95104
>
105+
{showBanner && <OutdatedTranslationBanner englishUrl={englishUrl} locale={currentLocale} />}
96106
<div class="content-grid mt-0 max-w-[770px]">
97107
<div class="col-span-9 xl:min-w-[1000px]">
98108
{entry.data.beta && (

src/layouts/TextDetailLayout.astro

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import BaseLayout from "./BaseLayout.astro";
44
import type { CollectionEntry } from "astro:content";
55
import { setJumpToState } from "../globals/state";
66
import { getCurrentLocale } from "../i18n/utils";
7+
import OutdatedTranslationBanner from "@components/OutdatedTranslationBanner/index.astro";
8+
import { checkTranslationBanner } from "../utils/translationBanner";
79
810
interface Props {
911
page: CollectionEntry<"text-detail">;
@@ -19,6 +21,14 @@ const pageTopic = Astro.url.pathname.includes("donate")
1921
const currentLocale = getCurrentLocale(Astro.url.pathname);
2022
2123
setJumpToState(null);
24+
25+
const { showBanner, englishUrl } = checkTranslationBanner(
26+
'text-detail',
27+
page.id,
28+
currentLocale,
29+
Astro.url.pathname,
30+
Astro.url.origin
31+
);
2232
---
2333

2434
<Head title={page.data.title} locale={currentLocale} />
@@ -30,6 +40,7 @@ setJumpToState(null);
3040
className={pageTopic}
3141
subtitle={null}
3242
>
43+
{showBanner && <OutdatedTranslationBanner englishUrl={englishUrl} locale={currentLocale} />}
3344
<div class="max-w-[770px] [&>*:first-child]:mt-0 rendered-markdown pb-[80px]">
3445
<Content />
3546
</div>

0 commit comments

Comments
 (0)