Skip to content

Commit b937a3b

Browse files
committed
update translations
1 parent e354e27 commit b937a3b

14 files changed

+102
-111
lines changed

website/src/components/templates/BaseTemplate.tsx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FC, PropsWithChildren } from "hono/jsx";
2-
import { menuTranslations } from "../../translations";
2+
import { t } from "../../translations";
33
import type { Page } from "../../types/model";
44
import { getTranslationStatus } from "../../utils/translationStatus";
55
import {
@@ -43,11 +43,11 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
4343
const outline = page.outline;
4444
const translationStatus = getTranslationStatus(route);
4545
return (
46-
<html lang={menuTranslations.lang} class="scroll-pt-24">
46+
<html lang={t("lang")} class="scroll-pt-24">
4747
<head>
4848
<meta charSet="utf-8" />
4949
<title>
50-
{title}{menuTranslations.documentationTitle}
50+
{title}{t("documentationTitle")}
5151
</title>
5252
<meta name="description" content={description} />
5353
<meta name="viewport" content="width=device-width,initial-scale=1" />
@@ -58,7 +58,7 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
5858
/>
5959
<meta
6060
property="og:title"
61-
content={`${title}${menuTranslations.documentationTitle}`}
61+
content={`${title}${t("documentationTitle")}`}
6262
/>
6363
<meta property="og:site_name" content="Typst" />
6464
<meta property="og:description" content={description} />
@@ -155,7 +155,7 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
155155
type="button"
156156
class="text-gray-600"
157157
x-on:click="sidebarOpen = false"
158-
aria-label={menuTranslations.closeMenu}
158+
aria-label={t("closeMenu")}
159159
>
160160
<div class="w-6 h-6 text-gray-600 hover:text-gray-800 transition-colors">
161161
<CloseIcon />
@@ -195,7 +195,7 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
195195
<div class="w-4 h-4 mr-1 ">
196196
<WorldIcon />
197197
</div>
198-
{menuTranslations.originalArticle}
198+
{t("originalArticle")}
199199
</a>
200200
</div>
201201
)}
@@ -215,7 +215,7 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
215215
<WorldIcon />
216216
</div>
217217
<span class="text-sm font-medium text-gray-800 group-hover:text-gray-900 transition-colors">
218-
{menuTranslations.originalArticle}
218+
{t("originalArticle")}
219219
</span>
220220
<div class="w-4 h-4 ml-2 text-gray-400 transition-colors">
221221
<ChevronRightIcon />
@@ -234,12 +234,10 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
234234
<CaretRightCircleIcon />
235235
</div>
236236
<strong class="text-base font-semibold text-gray-800">
237-
{menuTranslations.tutorial}
237+
{t("tutorial")}
238238
</strong>
239239
</div>
240-
<p class="text-sm text-gray-600">
241-
{menuTranslations.learnTypst}
242-
</p>
240+
<p class="text-sm text-gray-600">{t("learnTypst")}</p>
243241
</a>
244242
<a
245243
class="doc-category flex flex-col p-6 bg-white border border-gray-200 rounded-lg hover:border-gray-500 hover:bg-gray-50 transition-all duration-200"
@@ -250,12 +248,10 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
250248
<InfoCircleIcon />
251249
</div>
252250
<strong class="text-base font-semibold text-gray-800">
253-
{menuTranslations.referenceTo}
251+
{t("referenceTo")}
254252
</strong>
255253
</div>
256-
<p class="text-sm text-gray-600">
257-
{menuTranslations.reference}
258-
</p>
254+
<p class="text-sm text-gray-600">{t("reference")}</p>
259255
</a>
260256
</div>
261257
) : (
@@ -271,7 +267,7 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
271267
<ChevronLeftIcon />
272268
</div>
273269
<strong class="text-base font-semibold text-gray-800">
274-
{menuTranslations.previousPage}
270+
{t("previousPage")}
275271
</strong>
276272
</div>
277273
<p class="text-sm text-gray-600">{previousPage.title}</p>
@@ -282,7 +278,7 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
282278
>
283279
<div class="flex items-center mb-3 justify-between">
284280
<strong class="text-base font-semibold text-gray-800">
285-
{menuTranslations.nextPage}
281+
{t("nextPage")}
286282
</strong>
287283
<div class="w-6 h-6 text-gray-400">
288284
<ChevronRightIcon />

website/src/components/templates/CategoryTemplate.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FC } from "hono/jsx";
2-
import { menuTranslations } from "../../translations";
2+
import { t } from "../../translations";
33
import type { CategoryBody, Page } from "../../types/model";
44
import { HtmlContent } from "../ui/HtmlContent";
55
import BaseTemplate, { type BaseTemplateProps } from "./BaseTemplate";
@@ -27,7 +27,7 @@ export const CategoryTemplate: FC<CategoryTemplateProps> = ({
2727
>
2828
<h1 id="summary">{page.body.content.title}</h1>
2929
<HtmlContent html={page.body.content.details} />
30-
<h2 id="definitions">{menuTranslations.definition}</h2>
30+
<h2 id="definitions">{t("definition")}</h2>
3131
<ul class="subgridded">
3232
{page.body.content.items.map((item) => (
3333
<li key={item.route}>

website/src/components/templates/FuncTemplate.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FC } from "hono/jsx";
2-
import { menuTranslations } from "../../translations";
2+
import { t } from "../../translations";
33
import type { Func, FuncBody, Page } from "../../types/model";
44
import {
55
FunctionDefinition,
@@ -53,7 +53,7 @@ export const FuncTemplate: FC<FuncTemplateProps> = ({
5353
</div>
5454

5555
<h2 id="parameters" class="flex items-baseline gap-1">
56-
{menuTranslations.argument}
56+
{t("argument")}
5757
<Tooltip kind="parameters" />
5858
</h2>
5959

@@ -83,7 +83,10 @@ export const FuncTemplate: FC<FuncTemplateProps> = ({
8383
function ScopedDefinitions({
8484
scope,
8585
parent,
86-
}: { scope: Func[]; parent?: { name: string; id: string } | undefined }) {
86+
}: {
87+
scope: Func[];
88+
parent?: { name: string; id: string } | undefined;
89+
}) {
8790
if (scope.length === 0) {
8891
return null;
8992
}
@@ -101,10 +104,10 @@ function ScopedDefinitions({
101104
// Therefore, it is sufficient to only annotate the direct `parent`.
102105
<>
103106
<code>{parent.name}</code>
104-
{menuTranslations.definitionOf}
107+
{t("definitionOf")}
105108
</>
106109
) : (
107-
menuTranslations.definition
110+
t("definition")
108111
)}
109112
<Tooltip kind="definitions" />
110113
</h2>

website/src/components/templates/TypeTemplate.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FC } from "hono/jsx";
2-
import { menuTranslations } from "../../translations";
2+
import { t } from "../../translations";
33
import type { Page, TypeBody } from "../../types/model";
44
import { FunctionDisplay, Tooltip } from "../ui";
55
import { HtmlContent } from "../ui/HtmlContent";
@@ -39,7 +39,7 @@ export const TypeTemplate: FC<TypeTemplateProps> = ({
3939
{content.constructor && (
4040
<>
4141
<h2 id="constructor" class="flex items-center gap-1">
42-
{menuTranslations.constructor}
42+
{t("constructor")}
4343
<Tooltip kind="parameters" />
4444
</h2>
4545

@@ -54,7 +54,7 @@ export const TypeTemplate: FC<TypeTemplateProps> = ({
5454
{content.scope.length > 0 && (
5555
<>
5656
<h2 id="definitions" class="flex items-center gap-1">
57-
{menuTranslations.definition}
57+
{t("definition")}
5858
<Tooltip kind="definitions" />
5959
</h2>
6060

website/src/components/ui/FunctionDisplay.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FC } from "hono/jsx";
2-
import { menuTranslations } from "../../translations";
2+
import { t } from "../../translations";
33
import type { Func } from "../../types/model";
44
import { ChevronRightIcon } from "../icons";
55
import { FunctionDefinition } from "./FunctionDefinition";
@@ -36,7 +36,7 @@ export const FunctionDisplay: FC<FunctionDisplayProps> = ({
3636
<div class="w-4 h-4 text-gray-400 transform transition-transform duration-200 group-open:rotate-90">
3737
<ChevronRightIcon />
3838
</div>
39-
{menuTranslations.showExample}
39+
{t("showExample")}
4040
</summary>
4141
<div class="mt-2 bg-white p-3 rounded-md border border-gray-200 text-sm">
4242
<HtmlContent html={func.example} />

website/src/components/ui/FunctionParameters.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FC } from "hono/jsx";
2-
import { menuTranslations } from "../../translations";
2+
import { t } from "../../translations";
33
import type { Func } from "../../types/model";
44
import { ChevronRightIcon } from "../icons";
55
import { HtmlContent } from "./HtmlContent";
@@ -61,7 +61,7 @@ export const FunctionParameters: FC<FunctionParametersProps> = ({
6161
{param.strings.length > 0 && (
6262
<div class="mt-3">
6363
<h5 class="text-sm font-medium text-gray-700 mb-2">
64-
{menuTranslations.stringValues}:
64+
{t("stringValues")}:
6565
</h5>
6666
<ul class="type-args space-y-2 pl-4">
6767
{param.strings.map((string) => (
@@ -82,7 +82,7 @@ export const FunctionParameters: FC<FunctionParametersProps> = ({
8282

8383
{param.default && (
8484
<p class="mt-3 text-sm">
85-
<span class="font-medium">{menuTranslations.defaultValue}:</span>{" "}
85+
<span class="font-medium">{t("defaultValue")}:</span>{" "}
8686
<span class="text-gray-700">
8787
<HtmlContent html={param.default} />
8888
</span>
@@ -95,7 +95,7 @@ export const FunctionParameters: FC<FunctionParametersProps> = ({
9595
<div class="w-4 h-4 text-gray-400 transform transition-transform duration-200 group-open:rotate-90">
9696
<ChevronRightIcon />
9797
</div>
98-
{menuTranslations.showExample}
98+
{t("showExample")}
9999
</summary>
100100
<div class="mt-2 bg-white p-3 rounded-md border border-gray-200 text-sm">
101101
<HtmlContent html={param.example} />

website/src/components/ui/Tooltip.tsx

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FC } from "hono/jsx";
2-
import { menuTranslations } from "../../translations";
2+
import { t } from "../../translations";
33
import { CloseIcon, HelpCircleIcon } from "../icons";
44
import { HtmlContent } from "./HtmlContent";
55

@@ -26,57 +26,57 @@ const tooltipContent: Record<
2626
}
2727
> = {
2828
element: {
29-
label: menuTranslations.elementFunction,
30-
desc: menuTranslations.elementFunctionDesc,
29+
label: t("elementFunction"),
30+
desc: t("elementFunctionDesc"),
3131
isShowLabel: true,
3232
bgColor: "bg-blue-50",
3333
textColor: "text-blue-700",
3434
},
3535
contextual: {
36-
label: menuTranslations.contextFunction,
37-
desc: menuTranslations.contextFunctionDesc,
36+
label: t("contextFunction"),
37+
desc: t("contextFunctionDesc"),
3838
isShowLabel: true,
3939
bgColor: "bg-indigo-50",
4040
textColor: "text-indigo-700",
4141
},
4242
definitions: {
43-
label: menuTranslations.definitionTooltip,
44-
desc: menuTranslations.definitionTooltipDesc,
43+
label: t("definitionTooltip"),
44+
desc: t("definitionTooltipDesc"),
4545
isShowLabel: false,
4646
bgColor: "bg-gray-100",
4747
textColor: "text-gray-700",
4848
},
4949
parameters: {
50-
label: menuTranslations.argument,
51-
desc: menuTranslations.argumentDesc,
50+
label: t("argument"),
51+
desc: t("argumentDesc"),
5252
isShowLabel: false,
5353
bgColor: "bg-gray-100",
5454
textColor: "text-gray-700",
5555
},
5656
variadic: {
57-
label: menuTranslations.variadic,
58-
desc: menuTranslations.variadicDesc,
57+
label: t("variadic"),
58+
desc: t("variadicDesc"),
5959
isShowLabel: true,
6060
bgColor: "bg-green-50",
6161
textColor: "text-green-700",
6262
},
6363
settable: {
64-
label: menuTranslations.settable,
65-
desc: menuTranslations.settableDesc,
64+
label: t("settable"),
65+
desc: t("settableDesc"),
6666
isShowLabel: true,
6767
bgColor: "bg-amber-50",
6868
textColor: "text-amber-700",
6969
},
7070
positional: {
71-
label: menuTranslations.positional,
72-
desc: menuTranslations.positionalDesc,
71+
label: t("positional"),
72+
desc: t("positionalDesc"),
7373
isShowLabel: true,
7474
bgColor: "bg-purple-50",
7575
textColor: "text-purple-700",
7676
},
7777
required: {
78-
label: menuTranslations.required,
79-
desc: menuTranslations.requiredDesc,
78+
label: t("required"),
79+
desc: t("requiredDesc"),
8080
isShowLabel: true,
8181
bgColor: "bg-rose-50",
8282
textColor: "text-rose-700",
@@ -102,7 +102,7 @@ export const Tooltip: FC<TooltipProps> = ({ kind }) => {
102102
<button
103103
type="button"
104104
class="w-4 h-4 hover:bg-black/10 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 cursor-pointer"
105-
aria-label={`${content.label}${menuTranslations.showInformation}`}
105+
aria-label={`${content.label}${t("showInformation")}`}
106106
tabindex={0}
107107
{...{ "x-on:click": "helpOpen = true" }}
108108
{...{ "x-on:keydown.enter": "helpOpen = true" }}
@@ -147,17 +147,15 @@ export const Tooltip: FC<TooltipProps> = ({ kind }) => {
147147
{...{ "x-on:click": "helpOpen = false" }}
148148
{...{ "x-on:keydown.enter": "helpOpen = false" }}
149149
{...{ "x-on:keydown.space": "helpOpen = false" }}
150-
aria-label={menuTranslations.close}
150+
aria-label={t("close")}
151151
>
152152
<div class="w-6 h-6">
153153
<CloseIcon />
154154
</div>
155155
</button>
156156
</div>
157157
<div class="p-4">
158-
<div class="text-sm font-normal text-gray-700">
159-
<HtmlContent html={content.desc} />
160-
</div>
158+
<div class="text-sm font-normal text-gray-700">{content.desc}</div>
161159
</div>
162160
</div>
163161
</div>

0 commit comments

Comments
 (0)