Skip to content

Commit 115b884

Browse files
authored
Add Italian translation (#127)
1 parent 6a0f721 commit 115b884

18 files changed

+5861
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
temp
33
!.vscode
4+
__pycache__/

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.formatOnSave": false,
3+
}

README-it_IT.md

Lines changed: 4988 additions & 0 deletions
Large diffs are not rendered by default.

README-zh_CN.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
[中文](https://github.com/gibbok/typescript-book/blob/main/README-zh_CN.md)
1616

17+
[意大利](https://github.com/gibbok/typescript-book/blob/main/README-it_IT.md)
18+
1719
## 下载和网站
1820

1921
您还可以下载 Epub 版本:
@@ -247,7 +249,7 @@
247249

248250
## 关于作者
249251

250-
Simone Poggiali 是一位经验丰富的高级前端开发人员,自 90 年代以来就热衷于编写专业级代码。在他的国际职业生涯中,他为从初创公司到大型组织的广泛客户提供了众多项目。HelloFresh、Siemens、O2Leroy Merlin 等著名公司都受益于他的专业知识和奉献精神
252+
Simone Poggiali 是一位经验丰富的资深工程师,自 90 年代以来便对编写专业级代码充满热情。在他的国际职业生涯中,他曾为众多客户(从初创公司到大型企业)参与过各种项目。HelloFresh、西门子、O2Leroy Merlin 和 Snowplow 等知名公司都曾受益于他的专业知识和敬业精神
251253

252254
您可以通过以下平台联系 Simone Poggiali:
253255

@@ -546,7 +548,7 @@ tsconfig.json 文件用于配置 TypeScript 编译器 (tsc)。通常,它与文
546548

547549
[https://www.typescriptlang.org/tsconfig](https://www.typescriptlang.org/tsconfig)
548550

549-
[http://json.schemastore.org/tsconfig](http://json.schemastore.org/tsconfig)
551+
[https://www.typescriptlang.org/tsconfig/](https://www.typescriptlang.org/tsconfig/)
550552

551553
以下列出了常见且有用的配置:
552554

@@ -621,7 +623,13 @@ TypeScript 在为某些高级或低级 JavaScript 功能生成代码时使用帮
621623
第三步是在项目中包含第三方库的类型声明。 这些声明可以第三方库的类型声明文件或专门的声明包中找到,你能通过 [https://www.typescriptlang.org/dt/search](https://www.typescriptlang.org/dt/search) 搜索并安装它们。:
622624

623625
```shell
624-
npm install --save-dev @types/package-name or yarn add --dev @types/package-name.
626+
npm install --save-dev @types/package-name
627+
```
628+
629+
或者
630+
631+
```shell
632+
yarn add --dev @types/package-name
625633
```
626634

627635
第四步是使用自下而上的方法逐个模块地迁移,遵循从叶开始的依赖关系图。这个想法是开始转换不依赖于其他模块的模块。要可视化依赖关系图,您可以使用该madge工具。
@@ -4033,10 +4041,10 @@ const r = fn(['a', 'b'], 'c'); // 此处的类型为 ("a" | "b" | "c")[]
40334041
```typescript
40344042
// 使用 NoInfer 阻止类型推断的示例函数
40354043
function fn2<T extends string>(x: T[], y: NoInfer<T>) {
4036-
return x.concat(y);
4044+
return x.concat(y);
40374045
}
40384046
4039-
const r2 = fn2(["a", "b"], "c"); // 错误:类型为“c”的类型参数不能分配给类型为“a”|“b”的参数。
4047+
const r2 = fn2(['a', 'b'], 'c'); // 错误:类型为“c”的类型参数不能分配给类型为“a”|“b”的参数。
40404048
```
40414049

40424050
## 其他
@@ -4965,5 +4973,5 @@ import config from './config.json' with { type: 'json' };
49654973
49664974
<!-- skip -->
49674975
```typescript
4968-
const config = import("./config.json", { with: { type: "json" } })
4976+
const config = import('./config.json', { with: { type: 'json' } });
49694977
```

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ This book has been translated into several language versions, including:
1414

1515
[Chinese](https://github.com/gibbok/typescript-book/blob/main/README-zh_CN.md)
1616

17+
[Italian](https://github.com/gibbok/typescript-book/blob/main/README-it_IT.md)
18+
1719
## Downloads and website
1820

1921
You can also download the Epub version:
@@ -247,7 +249,7 @@ This book covers TypeScript 5.2.
247249

248250
## About the Author
249251

250-
Simone Poggiali is an experienced Senior Front-end Developer with a passion for writing professional-grade code since the 90s. Throughout his international career, he has contributed to numerous projects for a wide range of clients, from startups to large organizations. Notable companies such as HelloFresh, Siemens, O2, and Leroy Merlin have benefited from his expertise and dedication.
252+
Simone Poggiali is an experienced Staff Engineer with a passion for writing professional-grade code since the 90s. Throughout his international career, he has contributed to numerous projects for a wide range of clients, from startups to large organizations. Notable companies such as HelloFresh, Siemens, O2, Leroy Merlin and Snowplow have benefited from his expertise and dedication.
251253

252254
You can reach Simone Poggiali on the following platforms:
253255

@@ -554,7 +556,7 @@ At the following link you can find the complete documentation and its schema:
554556

555557
[https://www.typescriptlang.org/tsconfig](https://www.typescriptlang.org/tsconfig)
556558

557-
[http://json.schemastore.org/tsconfig](http://json.schemastore.org/tsconfig)
559+
[https://www.typescriptlang.org/tsconfig/](https://www.typescriptlang.org/tsconfig/)
558560

559561
The following represents a list of the common and useful configurations:
560562

@@ -629,7 +631,13 @@ The second step is to ensure that your JavaScript tests work alongside TypeScrip
629631
The third step is to include type declarations for third-party libraries in your project. These declarations can be found either bundled or on DefinitelyTyped. You can search for them using [https://www.typescriptlang.org/dt/search](https://www.typescriptlang.org/dt/search) and install them using:
630632

631633
```shell
632-
npm install --save-dev @types/package-name or yarn add --dev @types/package-name.
634+
npm install --save-dev @types/package-name
635+
```
636+
637+
or
638+
639+
```shell
640+
yarn add --dev @types/package-name.
633641
```
634642

635643
The fourth step is to migrate module by module with a bottom-up approach, following your Dependency Graph starting with the leaves. The idea is to start converting Modules that do not depend on other Modules. To visualize the dependency graphs, you can use the "madge" tool.

tools/check_toc.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import re
2+
import sys
3+
4+
def slugify(text):
5+
text = text.lower()
6+
text = re.sub(r'[^\w\s-]', '', text)
7+
text = re.sub(r'\s+', '-', text)
8+
return text
9+
10+
def check_toc(filepath):
11+
with open(filepath, 'r', encoding='utf-8') as f:
12+
lines = f.readlines()
13+
14+
headers = []
15+
toc_links = []
16+
17+
# Simple state machine to detect TOC section if needed,
18+
# but for now we'll just scan all lines for headers and links.
19+
# Actually, we should only care about links that look like internal anchors (#...)
20+
21+
for line in lines:
22+
line = line.strip()
23+
24+
# Detect headers
25+
header_match = re.match(r'^(#+)\s+(.+)$', line)
26+
if header_match:
27+
title = header_match.group(2).strip()
28+
# Ignore some specific things if needed, but generally:
29+
anchor = slugify(title)
30+
headers.append(anchor)
31+
32+
# Detect links
33+
# simple regex for markdown links [text](#anchor)
34+
# We perform findall because there might be multiple links in a line (though rare for TOC)
35+
links = re.findall(r'\[([^\]]+)\]\((#[^)]+)\)', line)
36+
for text, link in links:
37+
# clean the link (remove #)
38+
anchor_ref = link[1:]
39+
toc_links.append({'text': text, 'ref': anchor_ref})
40+
41+
# Verify
42+
broken_links = []
43+
for link in toc_links:
44+
if link['ref'] not in headers:
45+
# Special case: sometimes headers might have duplicate names and some markdown parsers handle it.
46+
# But normally GitHub appends -1, -2 etc. We might need to handle that if strict.
47+
# For now, let's just check existence.
48+
broken_links.append(link)
49+
50+
return broken_links
51+
52+
if __name__ == "__main__":
53+
if len(sys.argv) < 2:
54+
print("Usage: python3 check_toc.py <path_to_markdown>")
55+
sys.exit(1)
56+
57+
filepath = sys.argv[1]
58+
broken = check_toc(filepath)
59+
60+
if broken:
61+
print(f"Found {len(broken)} broken links:")
62+
for b in broken:
63+
print(f"- [{b['text']}](#{b['ref']}) -> Header not found (expected #{b['ref']})")
64+
else:
65+
print("No broken links found.")

tools/i18n.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
export enum Language {
22
en_EN = 'en_EN',
33
zh_CN = 'zh_CN',
4+
it_IT = 'it_IT',
45
}
5-
export type Languages = [Language.en_EN, Language.zh_CN]
6+
export type Languages = [Language.en_EN, Language.zh_CN, Language.it_IT]
67

7-
export const languages: Languages = [Language.en_EN, Language.zh_CN]
8+
export const languages: Languages = [Language.en_EN, Language.zh_CN, Language.it_IT]

tools/lint.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const lintCodeBlocksInMarkdownFile = async (filePath: string, options: PrettierO
1616
...options,
1717
});
1818
if (isCodeLinted === false) {
19+
const lineNumber = markdown.substring(0, match.index).split('\n').length;
20+
reportSnippetsNotLinted += `Line ${lineNumber}:\n`
1921
reportSnippetsNotLinted += code
2022
reportSnippetsNotLinted += '\n'
2123
}

tools/make-books.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ DIR_DOWNLOADS="downloads"
33

44
INPUT_EN="README"
55
INPUT_CN="README-zh_CN"
6+
INPUT_IT="README-it_IT"
67

78
OUTPUT_EN="typescript-book"
89
OUTPUT_CN="typescript-book-zh_CN"
10+
OUTPUT_IT="typescript-book-it_IT"
911

1012
AUTHOR="Simone Poggiali"
1113
TITLE_EN="The Concise TypeScript Book"
@@ -38,13 +40,16 @@ fi
3840
# Generate eBooks
3941
pandoc -o $DIR_DOWNLOADS/$OUTPUT_EN.epub --metadata title="$TITLE_EN" --metadata author="$AUTHOR" -s $INPUT_EN.md
4042
pandoc -o $DIR_DOWNLOADS/$OUTPUT_CN.epub --metadata title="$TITLE_CN" --metadata author="$AUTHOR" -s $INPUT_CN.md
43+
pandoc -o $DIR_DOWNLOADS/$OUTPUT_IT.epub --metadata title="$TITLE_IT" --metadata author="$AUTHOR" -s $INPUT_IT.md
4144

4245
# Validate eBooks
4346
epubcheck $DIR_DOWNLOADS/$OUTPUT_CN.epub
4447
epubcheck $DIR_DOWNLOADS/$OUTPUT_CN.epub
48+
epubcheck $DIR_DOWNLOADS/$OUTPUT_IT.epub
4549

4650
# Generate PDFs
4751
ebook-convert $DIR_DOWNLOADS/$OUTPUT_EN.epub $DIR_DOWNLOADS/$OUTPUT_EN.pdf --pdf-page-numbers
4852
ebook-convert $DIR_DOWNLOADS/$OUTPUT_CN.epub $DIR_DOWNLOADS/$OUTPUT_CN.pdf --pdf-page-numbers
53+
ebook-convert $DIR_DOWNLOADS/$OUTPUT_IT.epub $DIR_DOWNLOADS/$OUTPUT_IT.pdf --pdf-page-numbers
4954

5055
echo "Books were created. Please commit!"

tools/make-website-content.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
INPUT_FILE_PATH_CN = "../README-zh_CN.md"
2222
OUTPUT_DIR_PATH_CN = "../website/src/content/docs/zh-cn/book"
2323

24+
INPUT_FILE_PATH_IT = "../README-it_IT.md"
25+
OUTPUT_DIR_PATH_IT = "../website/src/content/docs/it-it/book"
26+
2427

2528
def manage_output_dir(path: str) -> None:
2629
if os.path.exists(path):
@@ -141,3 +144,5 @@ def process(base_input_path, input_lang_path: str, base_output_path: str) -> Non
141144
process(INPUT_FILE_PATH, INPUT_FILE_PATH, OUTPUT_DIR_PATH)
142145

143146
process(INPUT_FILE_PATH, INPUT_FILE_PATH_CN, OUTPUT_DIR_PATH_CN)
147+
148+
process(INPUT_FILE_PATH, INPUT_FILE_PATH_IT, OUTPUT_DIR_PATH_IT)

0 commit comments

Comments
 (0)