Skip to content

Commit b6f8202

Browse files
authored
docs: カテゴリページのタイトルと説明文を日本語に翻訳 (#265)
1 parent 2314d2a commit b6f8202

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

docs/src/lib.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,27 @@ fn category_page(resolver: &dyn Resolver, category: Category) -> PageModel {
345345
items.sort_by_cached_key(|item| item.name.clone());
346346
}
347347

348-
let title = EcoString::from(match category {
348+
let _title = EcoString::from(match category {
349349
Category::Pdf | Category::Html | Category::Png | Category::Svg => {
350350
category.name().to_uppercase()
351351
}
352352
_ => category.name().to_title_case(),
353353
});
354+
let translated_title = EcoString::from(match category {
355+
Category::Foundations => "基礎",
356+
Category::Model => "モデル",
357+
Category::Text => "文章",
358+
Category::Math => "数式",
359+
Category::Symbols => "記号",
360+
Category::Layout => "レイアウト",
361+
Category::Visualize => "視覚化",
362+
Category::Introspection => "内省",
363+
Category::DataLoading => "データの読み込み",
364+
Category::Pdf => "PDF",
365+
Category::Html => "HTML",
366+
Category::Svg => "SVG",
367+
Category::Png => "PNG",
368+
});
354369
let details = Html::markdown(resolver, docs, Some(1));
355370
let mut outline = vec![OutlineItem {
356371
id: "summary".into(),
@@ -369,30 +384,17 @@ fn category_page(resolver: &dyn Resolver, category: Category) -> PageModel {
369384
outline.push(OutlineItem::from_name("Shorthands"));
370385
}
371386

372-
let translated_title = match title.as_str() {
373-
"Foundations" => "基礎".into(),
374-
"Model" => "モデル".into(),
375-
"Text" => "文章".into(),
376-
"Math" => "数式".into(),
377-
"Symbols" => "記号".into(),
378-
"Layout" => "レイアウト".into(),
379-
"Visualize" => "視覚化".into(),
380-
"Introspection" => "内省".into(),
381-
"Data Loading" => "データの読み込み".into(),
382-
_ => title.clone(),
383-
};
384-
385387
PageModel {
386388
route,
387-
title: translated_title.into(),
389+
title: translated_title.clone().into(),
388390
description: eco_format!(
389-
"Documentation for functions related to {title} in Typst."
391+
"Typstにおける{translated_title}に関連する関数のドキュメント"
390392
),
391393
part: None,
392394
outline,
393395
body: BodyModel::Category(CategoryModel {
394396
name: category.name(),
395-
title: title.clone(),
397+
title: translated_title,
396398
details,
397399
items,
398400
shorthands,

website/src/components/templates/CategoryTemplate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const CategoryTemplate: FC<CategoryTemplateProps> = ({
2424
previousPage={previousPage}
2525
nextPage={nextPage}
2626
>
27-
<h1 id="summary">{page.body.content.name}</h1>
27+
<h1 id="summary">{page.body.content.title}</h1>
2828
<HtmlContent html={page.body.content.details} />
2929
<h2 id="definitions">定義</h2>
3030
<ul class="subgridded">

0 commit comments

Comments
 (0)