From 37d72cb2439c1bd7fdb4117f432f6b109584389c Mon Sep 17 00:00:00 2001 From: xihale Date: Wed, 27 Aug 2025 12:26:00 +0800 Subject: [PATCH 1/9] feat: i18n --- assets/style.css | 5 ++ i18n/en-US.ziggy | 9 +++ i18n/zh-CN.ziggy | 9 +++ layouts/section.shtml | 14 +++- layouts/templates/base.shtml | 2 +- .../01-01-read-file-line-by-line.smd | 0 src/{ => en-US}/01-02-mmap-file.smd | 0 .../01-03-file-modified-24h-ago.smd | 0 src/{ => en-US}/01-04-file-exists.smd | 0 src/{ => en-US}/01-05-iterate-dir.smd | 0 src/{ => en-US}/02-01-sha-digest.smd | 0 src/{ => en-US}/02-02-pbkdf2.smd | 0 src/{ => en-US}/03-01-elapsed-time.smd | 0 src/{ => en-US}/04-01-tcp-server.smd | 0 src/{ => en-US}/04-02-tcp-client.smd | 0 src/{ => en-US}/04-03-udp-echo.smd | 0 src/{ => en-US}/05-01-http-get.smd | 0 src/{ => en-US}/05-02-http-post.smd | 0 src/{ => en-US}/05-03-http-server-std.smd | 0 src/{ => en-US}/06-01-rand.smd | 0 src/{ => en-US}/07-01-spawn.smd | 0 src/{ => en-US}/07-02-shared-data.smd | 0 src/{ => en-US}/07-03-threadpool.smd | 0 src/{ => en-US}/07-04-run-once.smd | 0 src/{ => en-US}/08-01-cpu-count.smd | 0 src/{ => en-US}/08-02-external.smd | 0 src/{ => en-US}/09-01-semver.smd | 0 src/{ => en-US}/10-01-json.smd | 0 src/{ => en-US}/10-02-zon.smd | 0 src/{ => en-US}/10-03-base64.smd | 0 src/{ => en-US}/11-01-complex-numbers.smd | 0 src/{ => en-US}/12-01-bitfield.smd | 0 src/{ => en-US}/12-02-singly-linked-list.smd | 0 src/{ => en-US}/12-03-doubly-linked-list.smd | 0 src/{ => en-US}/13-01-argparse.smd | 0 src/{ => en-US}/14-01-sqlite.smd | 0 src/{ => en-US}/14-02-postgres.smd | 0 src/{ => en-US}/14-03-mysql.smd | 0 src/{ => en-US}/15-01-regex.smd | 0 src/{ => en-US}/15-02-string.smd | 0 src/{ => en-US}/database.smd | 0 src/{ => en-US}/index.smd | 9 ++- src/{ => en-US}/toc.smd | 4 +- src/zh-CN/index.smd | 70 +++++++++++++++++++ src/zh-CN/toc.smd | 8 +++ zine.ziggy | 20 +++++- 46 files changed, 138 insertions(+), 12 deletions(-) create mode 100644 i18n/en-US.ziggy create mode 100644 i18n/zh-CN.ziggy rename src/{ => en-US}/01-01-read-file-line-by-line.smd (100%) rename src/{ => en-US}/01-02-mmap-file.smd (100%) rename src/{ => en-US}/01-03-file-modified-24h-ago.smd (100%) rename src/{ => en-US}/01-04-file-exists.smd (100%) rename src/{ => en-US}/01-05-iterate-dir.smd (100%) rename src/{ => en-US}/02-01-sha-digest.smd (100%) rename src/{ => en-US}/02-02-pbkdf2.smd (100%) rename src/{ => en-US}/03-01-elapsed-time.smd (100%) rename src/{ => en-US}/04-01-tcp-server.smd (100%) rename src/{ => en-US}/04-02-tcp-client.smd (100%) rename src/{ => en-US}/04-03-udp-echo.smd (100%) rename src/{ => en-US}/05-01-http-get.smd (100%) rename src/{ => en-US}/05-02-http-post.smd (100%) rename src/{ => en-US}/05-03-http-server-std.smd (100%) rename src/{ => en-US}/06-01-rand.smd (100%) rename src/{ => en-US}/07-01-spawn.smd (100%) rename src/{ => en-US}/07-02-shared-data.smd (100%) rename src/{ => en-US}/07-03-threadpool.smd (100%) rename src/{ => en-US}/07-04-run-once.smd (100%) rename src/{ => en-US}/08-01-cpu-count.smd (100%) rename src/{ => en-US}/08-02-external.smd (100%) rename src/{ => en-US}/09-01-semver.smd (100%) rename src/{ => en-US}/10-01-json.smd (100%) rename src/{ => en-US}/10-02-zon.smd (100%) rename src/{ => en-US}/10-03-base64.smd (100%) rename src/{ => en-US}/11-01-complex-numbers.smd (100%) rename src/{ => en-US}/12-01-bitfield.smd (100%) rename src/{ => en-US}/12-02-singly-linked-list.smd (100%) rename src/{ => en-US}/12-03-doubly-linked-list.smd (100%) rename src/{ => en-US}/13-01-argparse.smd (100%) rename src/{ => en-US}/14-01-sqlite.smd (100%) rename src/{ => en-US}/14-02-postgres.smd (100%) rename src/{ => en-US}/14-03-mysql.smd (100%) rename src/{ => en-US}/15-01-regex.smd (100%) rename src/{ => en-US}/15-02-string.smd (100%) rename src/{ => en-US}/database.smd (100%) rename src/{ => en-US}/index.smd (87%) rename src/{ => en-US}/toc.smd (98%) create mode 100644 src/zh-CN/index.smd create mode 100644 src/zh-CN/toc.smd diff --git a/assets/style.css b/assets/style.css index d5bfde4..2b42942 100644 --- a/assets/style.css +++ b/assets/style.css @@ -291,4 +291,9 @@ html { h1{ margin-bottom: 0; +} +#content-header{ + margin-bottom: 10px; + padding-bottom: 10px; + border-bottom: 1px solid var(--border) } \ No newline at end of file diff --git a/i18n/en-US.ziggy b/i18n/en-US.ziggy new file mode 100644 index 0000000..e155be9 --- /dev/null +++ b/i18n/en-US.ziggy @@ -0,0 +1,9 @@ +{ + "site_title": "Zig Cookbook", + "introduction": "Introduction", + "contributing": "Contributing", + "license": "License", + "toggle_toc": "Toggle Table of Contents", + "language_switcher": "zh-CN", + "multilang_info": "Other language versions: ", +} \ No newline at end of file diff --git a/i18n/zh-CN.ziggy b/i18n/zh-CN.ziggy new file mode 100644 index 0000000..46bae71 --- /dev/null +++ b/i18n/zh-CN.ziggy @@ -0,0 +1,9 @@ +{ + "site_title": "Zig Cookbook", + "introduction": "引入", + "contributing": "贡献", + "license": "License", + "toggle_toc": "切换目录", + "language_switcher": "English", + "multilang_info": "其他语言版本: ", +} \ No newline at end of file diff --git a/layouts/section.shtml b/layouts/section.shtml index f5a7eae..c3f660a 100644 --- a/layouts/section.shtml +++ b/layouts/section.shtml @@ -4,8 +4,8 @@
- - + +
@@ -13,7 +13,15 @@
-

+
+

+ + + + + + +
diff --git a/layouts/templates/base.shtml b/layouts/templates/base.shtml index a260d01..26e2c2a 100644 --- a/layouts/templates/base.shtml +++ b/layouts/templates/base.shtml @@ -3,7 +3,7 @@ - + diff --git a/src/01-01-read-file-line-by-line.smd b/src/en-US/01-01-read-file-line-by-line.smd similarity index 100% rename from src/01-01-read-file-line-by-line.smd rename to src/en-US/01-01-read-file-line-by-line.smd diff --git a/src/01-02-mmap-file.smd b/src/en-US/01-02-mmap-file.smd similarity index 100% rename from src/01-02-mmap-file.smd rename to src/en-US/01-02-mmap-file.smd diff --git a/src/01-03-file-modified-24h-ago.smd b/src/en-US/01-03-file-modified-24h-ago.smd similarity index 100% rename from src/01-03-file-modified-24h-ago.smd rename to src/en-US/01-03-file-modified-24h-ago.smd diff --git a/src/01-04-file-exists.smd b/src/en-US/01-04-file-exists.smd similarity index 100% rename from src/01-04-file-exists.smd rename to src/en-US/01-04-file-exists.smd diff --git a/src/01-05-iterate-dir.smd b/src/en-US/01-05-iterate-dir.smd similarity index 100% rename from src/01-05-iterate-dir.smd rename to src/en-US/01-05-iterate-dir.smd diff --git a/src/02-01-sha-digest.smd b/src/en-US/02-01-sha-digest.smd similarity index 100% rename from src/02-01-sha-digest.smd rename to src/en-US/02-01-sha-digest.smd diff --git a/src/02-02-pbkdf2.smd b/src/en-US/02-02-pbkdf2.smd similarity index 100% rename from src/02-02-pbkdf2.smd rename to src/en-US/02-02-pbkdf2.smd diff --git a/src/03-01-elapsed-time.smd b/src/en-US/03-01-elapsed-time.smd similarity index 100% rename from src/03-01-elapsed-time.smd rename to src/en-US/03-01-elapsed-time.smd diff --git a/src/04-01-tcp-server.smd b/src/en-US/04-01-tcp-server.smd similarity index 100% rename from src/04-01-tcp-server.smd rename to src/en-US/04-01-tcp-server.smd diff --git a/src/04-02-tcp-client.smd b/src/en-US/04-02-tcp-client.smd similarity index 100% rename from src/04-02-tcp-client.smd rename to src/en-US/04-02-tcp-client.smd diff --git a/src/04-03-udp-echo.smd b/src/en-US/04-03-udp-echo.smd similarity index 100% rename from src/04-03-udp-echo.smd rename to src/en-US/04-03-udp-echo.smd diff --git a/src/05-01-http-get.smd b/src/en-US/05-01-http-get.smd similarity index 100% rename from src/05-01-http-get.smd rename to src/en-US/05-01-http-get.smd diff --git a/src/05-02-http-post.smd b/src/en-US/05-02-http-post.smd similarity index 100% rename from src/05-02-http-post.smd rename to src/en-US/05-02-http-post.smd diff --git a/src/05-03-http-server-std.smd b/src/en-US/05-03-http-server-std.smd similarity index 100% rename from src/05-03-http-server-std.smd rename to src/en-US/05-03-http-server-std.smd diff --git a/src/06-01-rand.smd b/src/en-US/06-01-rand.smd similarity index 100% rename from src/06-01-rand.smd rename to src/en-US/06-01-rand.smd diff --git a/src/07-01-spawn.smd b/src/en-US/07-01-spawn.smd similarity index 100% rename from src/07-01-spawn.smd rename to src/en-US/07-01-spawn.smd diff --git a/src/07-02-shared-data.smd b/src/en-US/07-02-shared-data.smd similarity index 100% rename from src/07-02-shared-data.smd rename to src/en-US/07-02-shared-data.smd diff --git a/src/07-03-threadpool.smd b/src/en-US/07-03-threadpool.smd similarity index 100% rename from src/07-03-threadpool.smd rename to src/en-US/07-03-threadpool.smd diff --git a/src/07-04-run-once.smd b/src/en-US/07-04-run-once.smd similarity index 100% rename from src/07-04-run-once.smd rename to src/en-US/07-04-run-once.smd diff --git a/src/08-01-cpu-count.smd b/src/en-US/08-01-cpu-count.smd similarity index 100% rename from src/08-01-cpu-count.smd rename to src/en-US/08-01-cpu-count.smd diff --git a/src/08-02-external.smd b/src/en-US/08-02-external.smd similarity index 100% rename from src/08-02-external.smd rename to src/en-US/08-02-external.smd diff --git a/src/09-01-semver.smd b/src/en-US/09-01-semver.smd similarity index 100% rename from src/09-01-semver.smd rename to src/en-US/09-01-semver.smd diff --git a/src/10-01-json.smd b/src/en-US/10-01-json.smd similarity index 100% rename from src/10-01-json.smd rename to src/en-US/10-01-json.smd diff --git a/src/10-02-zon.smd b/src/en-US/10-02-zon.smd similarity index 100% rename from src/10-02-zon.smd rename to src/en-US/10-02-zon.smd diff --git a/src/10-03-base64.smd b/src/en-US/10-03-base64.smd similarity index 100% rename from src/10-03-base64.smd rename to src/en-US/10-03-base64.smd diff --git a/src/11-01-complex-numbers.smd b/src/en-US/11-01-complex-numbers.smd similarity index 100% rename from src/11-01-complex-numbers.smd rename to src/en-US/11-01-complex-numbers.smd diff --git a/src/12-01-bitfield.smd b/src/en-US/12-01-bitfield.smd similarity index 100% rename from src/12-01-bitfield.smd rename to src/en-US/12-01-bitfield.smd diff --git a/src/12-02-singly-linked-list.smd b/src/en-US/12-02-singly-linked-list.smd similarity index 100% rename from src/12-02-singly-linked-list.smd rename to src/en-US/12-02-singly-linked-list.smd diff --git a/src/12-03-doubly-linked-list.smd b/src/en-US/12-03-doubly-linked-list.smd similarity index 100% rename from src/12-03-doubly-linked-list.smd rename to src/en-US/12-03-doubly-linked-list.smd diff --git a/src/13-01-argparse.smd b/src/en-US/13-01-argparse.smd similarity index 100% rename from src/13-01-argparse.smd rename to src/en-US/13-01-argparse.smd diff --git a/src/14-01-sqlite.smd b/src/en-US/14-01-sqlite.smd similarity index 100% rename from src/14-01-sqlite.smd rename to src/en-US/14-01-sqlite.smd diff --git a/src/14-02-postgres.smd b/src/en-US/14-02-postgres.smd similarity index 100% rename from src/14-02-postgres.smd rename to src/en-US/14-02-postgres.smd diff --git a/src/14-03-mysql.smd b/src/en-US/14-03-mysql.smd similarity index 100% rename from src/14-03-mysql.smd rename to src/en-US/14-03-mysql.smd diff --git a/src/15-01-regex.smd b/src/en-US/15-01-regex.smd similarity index 100% rename from src/15-01-regex.smd rename to src/en-US/15-01-regex.smd diff --git a/src/15-02-string.smd b/src/en-US/15-02-string.smd similarity index 100% rename from src/15-02-string.smd rename to src/en-US/15-02-string.smd diff --git a/src/database.smd b/src/en-US/database.smd similarity index 100% rename from src/database.smd rename to src/en-US/database.smd diff --git a/src/index.smd b/src/en-US/index.smd similarity index 87% rename from src/index.smd rename to src/en-US/index.smd index 5e9020b..6d4c194 100644 --- a/src/index.smd +++ b/src/en-US/index.smd @@ -3,6 +3,7 @@ .date = "2024-01-01", .author = "ZigCC", .layout = "section.shtml", +.translation_key = "introduction", --- ```=html @@ -20,7 +21,7 @@ ``` -![Zig Cookbook Logo](/images/logo.webp) +![](/images/logo.webp) [Zig cookbook](https://github.com/zigcc/zig-cookbook) is a collection of simple Zig programs that demonstrate good practices to accomplish common programming tasks. @@ -29,7 +30,7 @@ # How to use -[The website](https://cookbook.ziglang.cc/) is generated by [zine-ssg](https://zine-ssg.io), a static site generator for Zig.`zine` will start a server at `http://localhost:1990` for preview. +[The website](https://cookbook.ziglang.cc/) is generated by [zine-ssg](https://zine-ssg.io), a static site generator for Zig. `zine` will start a server at `http://localhost:1990` for preview. Each recipe is accompanied by an illustrative example named after its corresponding sequence number. These examples can be executed using the command `zig build run-{chapter-num}-{sequence-num}`, or `zig build run-all` to execute all. @@ -42,6 +43,10 @@ Each recipe is accompanied by an illustrative example named after its correspond This cookbook is a work in progress, and we welcome contributions from the community. If you have a favorite recipe that you'd like to share, please submit a [pull request](https://github.com/zigcc/zig-cookbook/pulls). +## Localization + +Create corresponding recipe in the language you want to localize, localize it(make sure there is a `translation_key` in the frontmatter), and submit a pull request. + # Acknowledgment The **initial** version of the Zig Cookbook was inspired by several other similar projects. We would like to thank the following projects, thanks for their awesome work. diff --git a/src/toc.smd b/src/en-US/toc.smd similarity index 98% rename from src/toc.smd rename to src/en-US/toc.smd index 34edadb..661089e 100644 --- a/src/toc.smd +++ b/src/en-US/toc.smd @@ -1,12 +1,10 @@ --- -.title = "introduction", +.title = "toc", .date = "2024-01-01", .author = "ZigCC", .layout = "section.shtml", --- -# Summary - [Introduction](/) - File System diff --git a/src/zh-CN/index.smd b/src/zh-CN/index.smd new file mode 100644 index 0000000..7ae0dcb --- /dev/null +++ b/src/zh-CN/index.smd @@ -0,0 +1,70 @@ +--- +.title = "介绍", +.date = "2024-01-01", +.author = "ZigCC", +.layout = "section.shtml", +.translation_key = "introduction", +--- + +```=html + + 在Discord上聊天 + + + 星标数量 + + + CI + + + Pages + +``` + +![](/images/logo.webp) + +[Zig Cookbook](https://github.com/zigcc/zig-cookbook) 是一系列简单的 Zig 程序集合,用于展示完成常见编程任务的最佳实践。 + +> - 主分支跟踪 Zig 0.14.0 及 master 版本,并通过 GitHub Actions 在 Linux 和 macOS 上进行测试。 +> - 更早版本的 Zig 支持可在 [其他分支](https://github.com/zigcc/zig-cookbook/branches) 中找到。 + +# 如何使用 + +[网站](https://cookbook.ziglang.cc/) 由 [zine-ssg](https://zine-ssg.io) 生成,这是一个 Zig 编写的静态网站生成器。运行 `zine` 将在 `http://localhost:1990` 启动一个预览服务器。 + +每个示例都附带一个以对应序号命名的示例程序。可以使用命令 `zig build run-{章节号}-{序号}` 来运行单个示例,或使用 `zig build run-all` 运行所有示例。 + +> ## 注意 +> 某些示例可能依赖系统库: +> - 使用 `make install-deps` 安装客户端库; +> - 使用 `docker-compose up -d` 启动所需的数据库。 + +# 贡献 + +本 cookbook 仍在持续完善中,我们欢迎社区贡献。如果你有想要分享的示例,请 [Pull Request](https://github.com/zigcc/zig-cookbook/pulls)。 + +## 翻译 + +在对应语言目录下创建相应的要翻译的示例,翻译后 [Pull Request](https://github.com/zigcc/zig-cookbook/pulls) 即可(请确保 `frontmatter` 中有相应的 `translation_key`)。 + +# 联系我们 + +# 致谢 + +**初始版本**的 Zig Cookbook 受到多个类似项目的启发。我们向以下项目致以诚挚感谢,感谢它们的杰出工作: + +- [Rust Cookbook](https://github.com/rust-lang-nursery/rust-cookbook) + +**当前版本**的 Zig Cookbook 基于 [zine-ssg](https://zine-ssg.io),在此感谢其卓越的贡献! + +# 星标历史 + +```=html + + 星标历史 + +``` + +# 许可证 + +Markdown 文件采用 [CC BY-NC-ND 4.0 DEED](https://creativecommons.org/licenses/by-nc-nd/4.0/) 许可,Zig 源码文件采用 MIT 许可。 \ No newline at end of file diff --git a/src/zh-CN/toc.smd b/src/zh-CN/toc.smd new file mode 100644 index 0000000..211c314 --- /dev/null +++ b/src/zh-CN/toc.smd @@ -0,0 +1,8 @@ +--- +.title = "目录", +.date = "2024-01-01", +.author = "ZigCC", +.layout = "section.shtml", +--- + +[介绍](/) diff --git a/zine.ziggy b/zine.ziggy index d770804..7caae46 100644 --- a/zine.ziggy +++ b/zine.ziggy @@ -1,9 +1,23 @@ -Site { - .title = "Zig cookbook", +Multilingual { .host_url = "https://cookbook.ziglang.cc", - .content_dir_path = "src", + .i18n_dir_path = "i18n", .layouts_dir_path = "layouts", .assets_dir_path = "assets", .static_assets = [ ], + .locales = [ + { + .code = "en-US", + .name = "English", + .site_title = "Zig Cookbook", + .content_dir_path = "src/en-US", + .output_prefix_override = "", + }, + { + .code = "zh-CN", + .name = "中文", + .site_title = "Zig Cookbook", + .content_dir_path = "src/zh-CN", + }, + ], } From 7d2e37a175c7a4f0e58b902f1f415f5a7bc618b6 Mon Sep 17 00:00:00 2001 From: xihale Date: Wed, 27 Aug 2025 13:33:38 +0800 Subject: [PATCH 2/9] fix: readme --- README.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) mode change 120000 => 100644 README.md diff --git a/README.md b/README.md deleted file mode 120000 index 14300ad..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -book-src/intro.md \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4c3df6b --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# Zig Cookbook + +[![](https://img.shields.io/discord/1155469703846834187?label=Chat%20on%20Discord)](https://discord.gg/bAehMGPb2R) +[![](https://img.shields.io/github/stars/zigcc/zig-cookbook?style=square&color=#30a14e)](https://github.com/zigcc/zig-cookbook/stargazers) +[![](https://github.com/zigcc/zig-cookbook/actions/workflows/ci.yml/badge.svg)](https://github.com/zigcc/zig-cookbook/actions/workflows/ci.yml) +[![](https://github.com/zigcc/zig-cookbook/actions/workflows/pages.yml/badge.svg)](https://github.com/zigcc/zig-cookbook/actions/workflows/pages.yml) + +![Zig Cookbook Logo](./assets/images/logo.webp) + +[Zig cookbook](https://github.com/zigcc/zig-cookbook) is a collection of simple Zig programs that demonstrate good practices to accomplish common programming tasks. + +> - Main branch tracks Zig 0.14.0 and master, and are tested on Linux and macOS via GitHub actions. +> - Earlier Zig support could be found in [other branches](https://github.com/zigcc/zig-cookbook/branches). + +# How to use + +[The website](https://cookbook.ziglang.cc/) is generated by [zine-ssg](https://zine-ssg.io), a static site generator for Zig. `zine` will start a server at `http://localhost:1990` for preview. + +Each recipe is accompanied by an illustrative example named after its corresponding sequence number. These examples can be executed using the command `zig build run-{chapter-num}-{sequence-num}`, or `zig build run-all` to execute all. + +> ## Note +> +> Some recipes may depend on system libraries +> +> - Use `make install-deps` to install client libraries, and +> - `docker-compose up -d` to start required databases. + +# Contributing + +This cookbook is a work in progress, and we welcome contributions from the community. If you have a favorite recipe that you'd like to share, please submit a [pull request](https://github.com/zigcc/zig-cookbook/pulls). + +## Localization + +Create corresponding recipe in the language folder, localize it, and submit a [pull request](https://github.com/zigcc/zig-cookbook/pulls). + +# Acknowledgment + +The **initial** version of the Zig Cookbook was inspired by several other similar projects. We would like to thank the following projects, thanks for their awesome work. + +- [Rust Cookbook](https://github.com/rust-lang-nursery/rust-cookbook) + +The **current** version of the Zig Cookbook is based on [zine-ssg](https://zine-ssg.io), thanks for their awesome work. + +# Star History + +```=html + + Star History + +``` + +# License + +The markdown files are licensed under [CC BY-NC-ND 4.0 DEED](https://creativecommons.org/licenses/by-nc-nd/4.0/), and zig files are under MIT. From 122d67a8a128c96626a763ab6125778e43c9ac9e Mon Sep 17 00:00:00 2001 From: xihale Date: Wed, 27 Aug 2025 14:45:28 +0800 Subject: [PATCH 3/9] fix: zh-CN introduction --- src/zh-CN/index.smd | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/zh-CN/index.smd b/src/zh-CN/index.smd index 7ae0dcb..243a460 100644 --- a/src/zh-CN/index.smd +++ b/src/zh-CN/index.smd @@ -47,8 +47,6 @@ 在对应语言目录下创建相应的要翻译的示例,翻译后 [Pull Request](https://github.com/zigcc/zig-cookbook/pulls) 即可(请确保 `frontmatter` 中有相应的 `translation_key`)。 -# 联系我们 - # 致谢 **初始版本**的 Zig Cookbook 受到多个类似项目的启发。我们向以下项目致以诚挚感谢,感谢它们的杰出工作: @@ -67,4 +65,4 @@ # 许可证 -Markdown 文件采用 [CC BY-NC-ND 4.0 DEED](https://creativecommons.org/licenses/by-nc-nd/4.0/) 许可,Zig 源码文件采用 MIT 许可。 \ No newline at end of file +Markdown 文件采用 [CC BY-NC-ND 4.0 DEED](https://creativecommons.org/licenses/by-nc-nd/4.0/) 许可,Zig 源码文件采用 MIT 许可。 From e823d6f2caafc6a8915bdec3ef7ef7771df869a7 Mon Sep 17 00:00:00 2001 From: xihale Date: Wed, 27 Aug 2025 14:48:49 +0800 Subject: [PATCH 4/9] fix: remove translation key & info --- src/en-US/index.smd | 3 +-- src/zh-CN/index.smd | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/en-US/index.smd b/src/en-US/index.smd index 6d4c194..7d16fdc 100644 --- a/src/en-US/index.smd +++ b/src/en-US/index.smd @@ -3,7 +3,6 @@ .date = "2024-01-01", .author = "ZigCC", .layout = "section.shtml", -.translation_key = "introduction", --- ```=html @@ -45,7 +44,7 @@ This cookbook is a work in progress, and we welcome contributions from the commu ## Localization -Create corresponding recipe in the language you want to localize, localize it(make sure there is a `translation_key` in the frontmatter), and submit a pull request. +Create corresponding recipe in the language you want to localize, localize it, and submit a pull request. # Acknowledgment diff --git a/src/zh-CN/index.smd b/src/zh-CN/index.smd index 243a460..7597631 100644 --- a/src/zh-CN/index.smd +++ b/src/zh-CN/index.smd @@ -3,7 +3,6 @@ .date = "2024-01-01", .author = "ZigCC", .layout = "section.shtml", -.translation_key = "introduction", --- ```=html @@ -45,7 +44,7 @@ ## 翻译 -在对应语言目录下创建相应的要翻译的示例,翻译后 [Pull Request](https://github.com/zigcc/zig-cookbook/pulls) 即可(请确保 `frontmatter` 中有相应的 `translation_key`)。 +在对应语言目录下创建相应的要翻译的示例,翻译后 [Pull Request](https://github.com/zigcc/zig-cookbook/pulls) 即可。 # 致谢 From c1b8cb82dc7686352ff67752b0176e941c0d1b5b Mon Sep 17 00:00:00 2001 From: xihale Date: Wed, 27 Aug 2025 14:59:02 +0800 Subject: [PATCH 5/9] fix: alternative lang --- i18n/en-US.ziggy | 4 ++-- i18n/zh-CN.ziggy | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/i18n/en-US.ziggy b/i18n/en-US.ziggy index e155be9..e2f7aa8 100644 --- a/i18n/en-US.ziggy +++ b/i18n/en-US.ziggy @@ -5,5 +5,5 @@ "license": "License", "toggle_toc": "Toggle Table of Contents", "language_switcher": "zh-CN", - "multilang_info": "Other language versions: ", -} \ No newline at end of file + "multilang_info": "其他语言: ", +} diff --git a/i18n/zh-CN.ziggy b/i18n/zh-CN.ziggy index 46bae71..18c250d 100644 --- a/i18n/zh-CN.ziggy +++ b/i18n/zh-CN.ziggy @@ -5,5 +5,5 @@ "license": "License", "toggle_toc": "切换目录", "language_switcher": "English", - "multilang_info": "其他语言版本: ", -} \ No newline at end of file + "multilang_info": "alternative lang: ", +} From 095b167d5ed570f40392242d5cc7fcaea91ced32 Mon Sep 17 00:00:00 2001 From: xihale Date: Wed, 27 Aug 2025 18:38:01 +0800 Subject: [PATCH 6/9] feat(footer): add copyright & multilingual link style: prev-next block --- assets/style.css | 35 +++++++++++------------------------ i18n/en-US.ziggy | 7 +++++-- i18n/zh-CN.ziggy | 5 +++-- layouts/section.shtml | 39 +++++++++++++++++++++------------------ 4 files changed, 40 insertions(+), 46 deletions(-) diff --git a/assets/style.css b/assets/style.css index 2b42942..f3b787c 100644 --- a/assets/style.css +++ b/assets/style.css @@ -70,28 +70,8 @@ body { } #prev-next { - display: flex; - justify-content: space-between; - flex-wrap: wrap; - align-items: center; - margin-top: 20px; - padding-top: 5px; - border-top: 2px solid var(--border); -} - -#prev-next a { - text-decoration: none; -} -#prev-next > :last-child { - margin-left: auto; - text-align: right; -} -#prev-next > :first-child span::before { - content: "←"; -} - -#prev-next > :last-child span::after { - content: "→"; + padding: 15px 0; + border-bottom: 1px solid var(--border); } a { @@ -165,6 +145,14 @@ html { max-width: 50rem; } +article { + border-bottom: 1px solid var(--border); +} + +footer { + margin: 15px 0; +} + .toc { width: var(--toc-width); min-width: var(--toc-width); @@ -176,12 +164,11 @@ html { /* word-break: normal; */ } .toc a { - text-decoration: none; line-break: auto; } .toc a:hover { - text-decoration: underline; + color: #5eafcd; } .toc a[aria-current="page"] { diff --git a/i18n/en-US.ziggy b/i18n/en-US.ziggy index e2f7aa8..16d0e05 100644 --- a/i18n/en-US.ziggy +++ b/i18n/en-US.ziggy @@ -5,5 +5,8 @@ "license": "License", "toggle_toc": "Toggle Table of Contents", "language_switcher": "zh-CN", - "multilang_info": "其他语言: ", -} + "prev": "Previous: ", + "next": "Next: ", + "languages_menu": "This page is available in the following languages:", + "footer_copyright": "License: text: CC BY-SA 4.0; code: MIT", +} diff --git a/i18n/zh-CN.ziggy b/i18n/zh-CN.ziggy index 18c250d..d42d019 100644 --- a/i18n/zh-CN.ziggy +++ b/i18n/zh-CN.ziggy @@ -5,5 +5,6 @@ "license": "License", "toggle_toc": "切换目录", "language_switcher": "English", - "multilang_info": "alternative lang: ", -} + "languages_menu": "此页面提供以下语言的版本:", + "footer_copyright": "许可证: 文字:CC BY-NC-SA 4.0;代码:MIT", +} diff --git a/layouts/section.shtml b/layouts/section.shtml index c3f660a..207315b 100644 --- a/layouts/section.shtml +++ b/layouts/section.shtml @@ -15,27 +15,30 @@

- - - - - -
-
-
- - - -
-
- - - + +
+
+ +
+
+ +
-
+ +
+
© 2025. All rights reserved.
+
+ + + + +
- \ No newline at end of file + From 59a337f80ab3e009499579788e1cabae2f473142 Mon Sep 17 00:00:00 2001 From: xihale Date: Wed, 27 Aug 2025 19:54:48 +0800 Subject: [PATCH 7/9] fix: footer --- assets/style.css | 3 ++- layouts/section.shtml | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/assets/style.css b/assets/style.css index f3b787c..61ba5a3 100644 --- a/assets/style.css +++ b/assets/style.css @@ -149,8 +149,9 @@ article { border-bottom: 1px solid var(--border); } -footer { +#footer { margin: 15px 0; + text-align: center; } .toc { diff --git a/layouts/section.shtml b/layouts/section.shtml index 207315b..2b514a1 100644 --- a/layouts/section.shtml +++ b/layouts/section.shtml @@ -28,17 +28,16 @@
-
+
+
+ + + +
- + \ No newline at end of file From 7709de4bc921ac431d45f4a576d47975560be90b Mon Sep 17 00:00:00 2001 From: xihale Date: Wed, 27 Aug 2025 20:19:02 +0800 Subject: [PATCH 8/9] style: footer --- assets/style.css | 5 +++++ i18n/en-US.ziggy | 2 +- i18n/zh-CN.ziggy | 2 +- layouts/section.shtml | 13 ++++++------- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/assets/style.css b/assets/style.css index 61ba5a3..e50c7e6 100644 --- a/assets/style.css +++ b/assets/style.css @@ -152,6 +152,11 @@ article { #footer { margin: 15px 0; text-align: center; + font-size: 0.85rem; +} + +#footer .langs * { + margin: 0 5px; } .toc { diff --git a/i18n/en-US.ziggy b/i18n/en-US.ziggy index 16d0e05..c5af087 100644 --- a/i18n/en-US.ziggy +++ b/i18n/en-US.ziggy @@ -7,6 +7,6 @@ "language_switcher": "zh-CN", "prev": "Previous: ", "next": "Next: ", - "languages_menu": "This page is available in the following languages:", + "languages_menu": "This page is available in the following languages", "footer_copyright": "License: text: CC BY-SA 4.0; code: MIT", } diff --git a/i18n/zh-CN.ziggy b/i18n/zh-CN.ziggy index d42d019..e209259 100644 --- a/i18n/zh-CN.ziggy +++ b/i18n/zh-CN.ziggy @@ -5,6 +5,6 @@ "license": "License", "toggle_toc": "切换目录", "language_switcher": "English", - "languages_menu": "此页面提供以下语言的版本:", + "languages_menu": "此页面提供以下语言的版本", "footer_copyright": "许可证: 文字:CC BY-NC-SA 4.0;代码:MIT", } diff --git a/layouts/section.shtml b/layouts/section.shtml index 2b514a1..d81cfdd 100644 --- a/layouts/section.shtml +++ b/layouts/section.shtml @@ -31,13 +31,12 @@ - \ No newline at end of file + From 63364e887fbcbc978563113290fb2dd45fda2e85 Mon Sep 17 00:00:00 2001 From: xihale Date: Wed, 27 Aug 2025 21:06:35 +0800 Subject: [PATCH 9/9] fix: i18n table --- i18n/en-US.ziggy | 1 - i18n/zh-CN.ziggy | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/i18n/en-US.ziggy b/i18n/en-US.ziggy index c5af087..abb9b56 100644 --- a/i18n/en-US.ziggy +++ b/i18n/en-US.ziggy @@ -4,7 +4,6 @@ "contributing": "Contributing", "license": "License", "toggle_toc": "Toggle Table of Contents", - "language_switcher": "zh-CN", "prev": "Previous: ", "next": "Next: ", "languages_menu": "This page is available in the following languages", diff --git a/i18n/zh-CN.ziggy b/i18n/zh-CN.ziggy index e209259..e5ba3dd 100644 --- a/i18n/zh-CN.ziggy +++ b/i18n/zh-CN.ziggy @@ -1,10 +1,11 @@ { "site_title": "Zig Cookbook", - "introduction": "引入", + "introduction": "介绍", "contributing": "贡献", - "license": "License", + "license": "许可证", "toggle_toc": "切换目录", - "language_switcher": "English", + "prev": "上一示例:", + "next": "下一示例:", "languages_menu": "此页面提供以下语言的版本", "footer_copyright": "许可证: 文字:CC BY-NC-SA 4.0;代码:MIT", }