Skip to content

Commit

Permalink
Merge pull request #138 from permadao/i18n
Browse files Browse the repository at this point in the history
add Chinese lang config pack, fix the nav meta for all English page
  • Loading branch information
twilson63 committed Mar 21, 2024
2 parents 11254f5 + ea9d5fe commit fa6b0ac
Show file tree
Hide file tree
Showing 137 changed files with 6,672 additions and 177 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,13 @@ yarn-error.log*
# local env files
.env*.local


# typescript
*.tsbuildinfo
.vercel

src/.vitepress/cache
src/.vitepress/cache/deps
src/.vitepress/dist
.vitepress
.vitepress/cache
.vitepress/cache/deps

wallet.json

Expand Down
10 changes: 9 additions & 1 deletion languages/def.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
import { createRequire } from "node:module";

const enStrings = createRequire(import.meta.url)("./strings/en.json");
const zhStrings = createRequire(import.meta.url)("./strings/zh.json");
/**
* Start adding new languages by making a new language object inside the array
*
* @see file://./README.md#add-a-new-language
*/
const languages = [];
const languages = [
{
display: "中文", // Name of the language displayed in UI
name: "中文", // Name of the language in English, used by OpenAI translation
code: "zh", // 2 letter language code (ISO 639‑1)
strings: zhStrings, // JSON object of translated UI element strings
},
];

const i18n_strs = languages.reduce((langs, currentLang) => {
langs[currentLang.code] = currentLang.strings;
Expand Down
4 changes: 4 additions & 0 deletions languages/strings/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
"title": "Cookbook",
"description": "The decentralized computer with infinite threads.",
"edit": "Edit",
"on-this-page": "On this page",
"prev-page": "Previous page",
"next-page": "Next page",
"language": "Language",
"docs": "Docs",
"edit-link-text": "Suggest changes to this page",
"welcome": "Welcome",
"welcome-getting-started": "Getting Started",
"welcome-testnet-info": "Testnet Info",
Expand Down
82 changes: 82 additions & 0 deletions languages/strings/zh.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"label": "中文",
"display": "中文",
"lang": "zh",
"title": "手册",
"description": "拥有无限线程的去中心化计算机。",
"edit": "编辑",
"on-this-page": "本页内容",
"prev-page": "上一页",
"next-page": "下一页",
"edit-link-text": "对本页提出修改建议",
"language": "语言",
"docs": "文档",
"welcome": "欢迎",
"welcome-getting-started": "入门",
"welcome-testnet-info": "测试网信息",
"concepts": "概念",
"concepts-specs": "规范",
"concepts-messages": "消息",
"concepts-processes": "进程",
"concepts-units": "单元",
"concepts-how-it-works": "信使工作原理",
"concepts-meet-lua": "Lua 快速入门",
"concepts-tour": "aos 接口",
"guides": "指南",
"guides-aos": "aos",
"guides-aos-intro": "概览",
"guides-aos-installing": "安装",
"guides-aos-cli": "命令行",
"guides-aos-load": ".load",
"guides-aos-token": "创建代币",
"guides-aos-prompt": "自定义提示符",
"guides-aos-pingpong": "Ping-Pong 服务器",
"guides-aos-editor": "设置你的编辑器",
"guides-aos-inbox-and-handlers": "理解收件箱",
"guides-aos-troubleshooting": "使用 ao.link 进行故障排除",
"guides-aos-faq": "常见问题",
"guides-aos-blueprints": "蓝图",
"guides-aos-blueprints-token": "代币蓝图",
"guides-aos-blueprints-chatroom": "聊天室蓝图 ",
"guides-aos-blueprints-voting": "投票蓝图",
"guides-aos-blueprints-staking": "质押蓝图",
"guides-aos-modules": "模块",
"guides-aos-modules-json": "JSON",
"guides-aos-modules-ao": "ao",
"guides-aos-modules-base64": "Base64",
"guides-aos-modules-pretty": "Pretty",
"guides-aos-modules-utils": "Utils",
"guides-aoconnect": "aoconnect",
"guides-calling-dryrun": "调用试运行",
"guides-connecting": "连接到节点",
"guides-monitoring-cron": "监控定时任务",
"guides-installing-connect": "安装 aoconnect",
"guides-reading-results": "读取结果",
"guides-sending-messages": "发送消息",
"guides-spawning-processes": "创建进程",
"tutorials": "教程",
"tutorials-begin": "开始",
"tutorials-begin-preparations": "准备",
"tutorials-begin-messaging": "消息传递",
"tutorials-begin-chatroom": "创建聊天室",
"tutorials-begin-token": "创建代币",
"tutorials-begin-tokengating": "代币门控",
"tutorials-bots-and-games": "机器人和游戏",
"tutorials-bots-and-games-ao-effect": "我们玩个游戏",
"tutorials-bots-and-games-announcements": "解析公告",
"tutorials-bots-and-games-game-state": "获取游戏状态",
"tutorials-bots-and-games-decisions": "战略决策",
"tutorials-bots-and-games-attacking": "自动反馈",
"tutorials-bots-and-games-bringing-together": "整合一起",
"tutorials-bots-and-games-arena-mechanics": "竞技场的机制",
"tutorials-bots-and-games-build-game": "扩展竞技场",
"references": "参考",
"references-lua": "Lua",
"references-wasm": "Web Assembly",
"references-ao": "ao 模块",
"references-handlers": "Handlers",
"references-token": "代币",
"references-data": "加载数据",
"references-cron": "定时消息",
"references-editor-setup": "ao 编辑器设置"
}
2 changes: 1 addition & 1 deletion src/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const config = defineConfig({
*/
locales: languages.reduce(
(locales, { code }) => {
locales[`/${code}/`] = localeConfig(code);
locales[code] = localeConfig(code);
return locales;
},
{ root: localeConfig("en") },
Expand Down
11 changes: 11 additions & 0 deletions src/.vitepress/locales.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ export const localeConfig = (langCode) => ({
title: get_i18n_str(langCode, "title"),
description: get_i18n_str(langCode, "description"),
themeConfig: {
outline: {
label: get_i18n_str(langCode, "on-this-page"),
},
docFooter: {
prev: get_i18n_str(langCode, "prev-page"),
next: get_i18n_str(langCode, "next-page"),
},
editLink: {
pattern: "https://github.com/permaweb/ao-cookbook/edit/main/src/:path",
text: get_i18n_str(langCode, "edit-link-text"),
},
logo: {
light: { src: "/ao_pictograph_lightmode.svg", height: 26, width: 26 },
dark: { src: "/ao_pictograph_darkmode.svg", height: 26, width: 26 },
Expand Down
8 changes: 4 additions & 4 deletions src/concepts/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
prev:
text: "Guides"
link: "/guides/index"
text: "Monitoring Cron"
link: "../guides/aoconnect/monitoring-cron"
next:
text: "References"
link: "/references/index"
text: "Specifications"
link: "./specs"
---

# Concepts
Expand Down
4 changes: 2 additions & 2 deletions src/concepts/processes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Processes

Processes possess the capability to engage in communication via message passing, both receiving and dispatching messages within the network. Additionally, they hold the potential to instantiate further processes, enhancing the network's computational fabric. This dynamic method of data dissemination and interaction within the network is referred to as a 'holographic state,' underpinning the shared and persistent state of the network.
Processes possess the capability to engage in communication via message passing, both receiving and dispatching messages within the network. Additionally, they hold the potential to instantiate further processes, enhancing the network's computational fabric. This dynamic method of data dissemination and interaction within the network is referred to as a 'holographic state', underpinning the shared and persistent state of the network.

![Process-Diagram](process-diagram.png)

Expand Down Expand Up @@ -62,7 +62,7 @@ ao.spawn(ao.env.Module.Id, {
The `ao.env` property contains the `Process` and `Module` Reference Objects

```
```lua
env = {
Process = {
Id = "5WzR7rJCuqCKEq02WUPhTjwnzllLjGu6SA7qhYpcKRs",
Expand Down
14 changes: 7 additions & 7 deletions src/concepts/tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,38 @@ Welcome to a quick tour of aos! This tutorial will walk you through the key glob
- **Functionality**: `Send(Message)` is a global function to send messages to other processes.
- **Usage Example**: `Send({Target = "...", Data = "Hello, Process!"})` sends a message with the data "Hello, Process!" to a specified process.

#### 3. Creating Processes with Spawn(Module, Message)
## 3. Creating Processes with Spawn(Module, Message)

- **Purpose**: Use `Spawn(Module, Message)` to create new processes.
- **Example**: `Spawn("MyModule", {Data = "Start"})` starts a new process using "MyModule" with the provided message.

#### 4. Understanding Name and Owner
## 4. Understanding Name and Owner

- **Name**: A string set during initialization, representing the process's name.
- **Owner**: Indicates the owner of the process. Changing this might restrict your ability to interact with your process.
- **Important Note**: Treat these as read-only to avoid issues.

#### 5. Utilizing Handlers
## 5. Utilizing Handlers

- **What They Are**: `Handlers` is a table of helper functions for creating message handlers.
- **Usage**: Define handlers in `Handlers` to specify actions for different incoming messages based on pattern matching.

#### 6. Data Representation with Dump
## 6. Data Representation with Dump

- **Function**: `Dump` converts any Lua table into a print-friendly format.
- **How to Use**: Useful for debugging or viewing complex table structures. Example: `Dump(Inbox)` prints the contents of `Inbox`.

#### 7. Leveraging Utils Module
## 7. Leveraging Utils Module

- **Contents**: Utils contains a collection of functional utilities like`map`, `reduce`, and `filter`.

- **Usage**: Great for data manipulation and functional programming patterns in Lua. For example, `Utils.map(myTable, function(x) return x * 2 end)` to double the values in a table.

#### 8. Exploring the ao Core Library
## 8. Exploring the ao Core Library

- **Description**: `ao` is a core module that includes key functions for message handling and process management.
- **Key Features**: Includes functions for sending messages (`send`) and spawning processes (`spawn`), along with environment variables.

#### Conclusion
## Conclusion

This brief tour introduces you to the primary globals and functionalities within the aos environment. With these tools at your disposal, you can create and manage processes, handle messages, and utilize Lua's capabilities to build efficient and responsive applications on the aos platform. Experiment with these features to get a deeper understanding and to see how they can be integrated into your specific use cases. Happy coding in aos!
9 changes: 9 additions & 0 deletions src/guides/aos/blueprints/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
---
prev:
text: "Build a Token"
link: "../token"
next:
text: "Token Blueprint"
link: "./token"
---

# Blueprints

Blueprints are predesigned templates that help you quickly build in `ao`. They are a great way to get started and can be customized to fit your needs.
Expand Down
9 changes: 9 additions & 0 deletions src/guides/aos/modules/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
---
prev:
text: "Staking Blueprint"
link: "../blueprints/staking"
next:
text: "JSON"
link: "./json"
---

# Modules

Documentation on all the built-in modules for aos.
Expand Down
8 changes: 4 additions & 4 deletions src/guides/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
prev:
text: "Tutorials"
link: "../tutorials/index"
text: "Expanding the Arena"
link: "/tutorials/bots-and-games/build-game"
next:
text: "Concepts"
link: "/concepts/index"
text: "aos"
link: "./aos/index"
---

# Guides
Expand Down
8 changes: 4 additions & 4 deletions src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ hero:
tagline: "Decentralized compute at any scale. Only possible on Arweave."
actions:
- theme: brand
text: Lets Go!
text: Let's Go!
link: /welcome/index

features:
- title: Tutorials.
- title: Tutorials
details: Follow the step-by-step tutorials to start building on ao.
link: /tutorials/index

- title: Guides.
- title: Guides
details: Bite size walkthroughs on specific features.
link: /guides/index

- title: Concepts.
- title: Concepts
details: Learn how the ao network works under the hood.
link: /concepts/index
---
8 changes: 4 additions & 4 deletions src/references/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
prev:
text: "Concepts"
link: "/concepts/index"
text: "The aos interface"
link: "/concepts/tour"
next:
text: "Getting Started"
link: "/references/lua"
text: "Lua"
link: "./lua"
---

# References
Expand Down
6 changes: 3 additions & 3 deletions src/tutorials/begin/chatroom.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ If she successfully joins the chatroom, she'll then pose the next challenge to y
- Provide Onboarding Instructions:
Share a simple script with them for easy onboarding:

```
Hey, let's chat on aos! Join my chatroom by sending this command in your aos environment:
```lua
-- Hey, let's chat on aos! Join my chatroom by sending this command in your aos environment:
Send({ Target = [Your Process ID], Action = "Register" })
Then, you can broadcast messages using:
-- Then, you can broadcast messages using:
Send({Target = [Your Process ID], Action = "Broadcast", Data = "Your Message" })
```

Expand Down
4 changes: 2 additions & 2 deletions src/tutorials/begin/dao.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ In our DAO we will implement a process knwon as "slashing". In the case of ao, i

Make a new directory called `dao` and copy in the token.lua created in the token guide.

```
```sh
mkdir dao
cd dao
cp ../token/token.lua .
```

Now create a new file called dao.lua and open it in your favorite editor.
Now create a new file called `dao.lua` and open it in your favorite editor.

## Writing the DAO code

Expand Down
8 changes: 4 additions & 4 deletions src/tutorials/begin/messaging.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Messaging in `ao`

### Learn how Messages gives `ao` Parallel Compute Capability
## Learn how Messages gives `ao` Parallel Compute Capability

In `ao`, every process runs in parallel, creating a highly scalable environment. Traditional direct function calls between processes aren't feasible because each process operates independently and asynchronously.

Expand Down Expand Up @@ -90,7 +90,7 @@ Send({ Target = Morpheus, Data = "Morpheus?" })
# Message is added to the outbox
message added to outbox
# A New Message is received from `Morpheus`'s process ID
New Message From BWM...ulw: Data = I am here. You are finally awake. Are yo
New Message From BWM...ulw: Data = I am here. You are f

```

Expand Down Expand Up @@ -167,7 +167,7 @@ Send Morpheus a message with the tag `Action` and the value `rabbithole`.
**Example:**
```sh
```lua
Send({ Target = Morpheus, Data = "Code: rabbithole", Action = "Unlock" })
```
Expand All @@ -184,7 +184,7 @@ Send({ Target = Morpheus, Data = "Code: rabbithole", Action = "Unlock" })
- **Workflow Management**: Tags can be instrumental in managing workflows, especially in systems where messages pass through multiple stages or processes.
## Additional Tips for Messaging:
## Additional Tips for Messaging
- **Message Structure**: Explore other fields like `Epoch`, `From`, and `Nonce` for more complex messaging needs.
- **Debugging**: Use the [`Dump`](/concepts/tour.html#_6-data-representation-with-dump) function to print messages for debugging.
Expand Down
3 changes: 1 addition & 2 deletions src/tutorials/begin/preparations.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
You've always known there's more to this world, just outside of your reach. You've been searching for it, not even knowing what it was you were looking for. It... is `ao`.

We begin our journey by installing the `aos` client and starting a new process. This will allow us to interact with the ao computer and complete the rest of the tutorial.

:::

## Video Tutorial
Expand Down Expand Up @@ -98,4 +97,4 @@ If your OS version is different than the latest version, a message asking if you

Welcome to your new home in the ao computer! The prompt you are now looking at is your own personal server in this decentralized machine.

Now, let's journey further down the rabbit hole by exploring one of the two core concept type of ao: [messaging.](messaging)
Now, let's journey further down the rabbit hole by exploring one of the two core concept type of ao: [messaging](messaging).
Loading

0 comments on commit fa6b0ac

Please sign in to comment.