Skip to content

Commit 824cd1e

Browse files
Link to translated microbit.org instead of /code
1 parent 900aa7e commit 824cd1e

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/external-links.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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)}`;

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)