Skip to content

Commit 4ccd6af

Browse files
Link to translated microbit.org (#1220)
Also, links logo to translated microbit.org instead of /code
1 parent 900aa7e commit 4ccd6af

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

src/documentation/ideas/IdeasDocumentation.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import { isV2Only } from "../common/model";
2222
import IdeaCard from "./IdeaCard";
2323
import { Idea } from "./model";
2424
import OfflineImageFallback from "../OfflineImageFallback";
25+
import { microbitOrgMiciProjectsUrl } from "../../external-links";
26+
import { useSettings } from "../../settings/settings";
2527

2628
interface IdeasDocumentationProps {
2729
ideas: Idea[];
@@ -64,6 +66,7 @@ const ActiveLevel = ({
6466
}: ActiveLevelProps) => {
6567
const activeIdea = ideas.find((idea) => idea.slug.current === ideaId);
6668
const intl = useIntl();
69+
const [{ languageId }] = useSettings();
6770
const headingString = intl.formatMessage({ id: "ideas-tab" });
6871
const ref = useRef<HTMLDivElement>(null);
6972
const contentRect = useResizeObserverContentRect(ref);
@@ -156,7 +159,7 @@ const ActiveLevel = ({
156159
link: (chunks: ReactNode) => (
157160
<Link
158161
color="brand.500"
159-
href="https://microbit.org/projects/make-it-code-it/?filters=python"
162+
href={microbitOrgMiciProjectsUrl(languageId)}
160163
target="_blank"
161164
rel="noopener"
162165
>

src/external-links.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const microbitOrgSupportedLangs = [
2+
"ar",
3+
"ca",
4+
"cy",
5+
"es-es",
6+
"fr",
7+
"hr",
8+
"ja",
9+
"ko",
10+
"nl",
11+
"pl",
12+
"pt-br",
13+
"pt-pt",
14+
"sr",
15+
"zh-cn",
16+
"zh-tw",
17+
];
18+
19+
const langPath = (languageId: string) => {
20+
const lang = languageId.toLowerCase();
21+
return microbitOrgSupportedLangs.includes(lang) ? `${lang}/` : "";
22+
};
23+
24+
export const microbitOrgUrl = (languageId: string) =>
25+
`https://microbit.org/${langPath(languageId)}`;
26+
27+
export const microbitOrgMiciProjectsUrl = (languageId: string) =>
28+
`https://microbit.org/${langPath(
29+
languageId
30+
)}projects/make-it-code-it/?filters=python`;

src/workbench/SideBarHeader.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { topBarHeight } from "../deployment/misc";
3030
import { supportedSearchLanguages } from "../documentation/search/search.worker";
3131
import { useSearch } from "../documentation/search/search-hooks";
3232
import SearchDialog from "../documentation/search/SearchDialog";
33+
import { microbitOrgUrl } from "../external-links";
3334
import { useLogging } from "../logging/logging-hooks";
3435
import { RouterState, useRouterState } from "../router-hooks";
3536
import { useSettings } from "../settings/settings";
@@ -186,7 +187,7 @@ const SideBarHeader = ({
186187
>
187188
<Link
188189
display="block"
189-
href="https://microbit.org/code/"
190+
href={microbitOrgUrl(languageId)}
190191
target="_blank"
191192
rel="noopener noreferrer"
192193
aria-label={intl.formatMessage({ id: "visit-dot-org" })}

0 commit comments

Comments
 (0)