Skip to content

feat: update some zh_CN translations of nu book #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ If Nushell is used as a login shell, you can use a specific configuration file w

The file `login.nu` is sourced after `env.nu` and `config.nu`, so that you can overwrite those configurations if you need.

There is an enviroment variable `$nu.loginshell-path` containing the path to this file.
There is an environment variable `$nu.loginshell-path` containing the path to this file.

### macOS: Keeping `/usr/bin/open` as `open`

Expand Down
2 changes: 1 addition & 1 deletion book/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ See [Defining environment from custom commands](environment.md#defining-environm

See [Modules](modules.md) for details.

## Reading environment varibles
## Reading environment variables

Individual environment variables are fields of a record that is stored in the `$env` variable and can be read with `$env.VARIABLE`:

Expand Down
24 changes: 12 additions & 12 deletions i18n-meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
"name": "README.md",
"en": "Completed",
"zh-CN": "b6c91cabfa@hustcer",
"zh-CN": "fa90895307@hustcer",
"de": "-",
"tr": "-",
"ja": "-",
Expand Down Expand Up @@ -62,7 +62,7 @@
{
"name": "configuration.md",
"en": "Completed",
"zh-CN": "008c89fc26@hustcer",
"zh-CN": "fa90895307@hustcer",
"de": "translated by @sebastian-xyz",
"tr": "-",
"ja": "-",
Expand Down Expand Up @@ -112,7 +112,7 @@
{
"name": "environment.md",
"en": "Completed",
"zh-CN": "008c89fc26@hustcer",
"zh-CN": "fa90895307@hustcer",
"de": "-",
"tr": "-",
"ja": "-",
Expand Down Expand Up @@ -142,7 +142,7 @@
{
"name": "installation.md",
"en": "Completed",
"zh-CN": "008c89fc26@hustcer",
"zh-CN": "fa90895307@hustcer",
"de": "translated by @sebastian-xyz",
"tr": "-",
"ja": "-",
Expand All @@ -162,7 +162,7 @@
{
"name": "loading_data.md",
"en": "Completed",
"zh-CN": "40925951fc@hustcer",
"zh-CN": "fa90895307@hustcer",
"de": "-",
"tr": "-",
"ja": "-",
Expand Down Expand Up @@ -192,7 +192,7 @@
{
"name": "moving_around.md",
"en": "Completed",
"zh-CN": "c13a71d11@hustcer",
"zh-CN": "fa90895307@hustcer",
"de": "-",
"tr": "-",
"ja": "-",
Expand All @@ -212,7 +212,7 @@
{
"name": "nushell_map_functional.md",
"en": "Completed",
"zh-CN": "ae23eeba3@hustcer",
"zh-CN": "fa90895307@hustcer",
"de": "-",
"tr": "-",
"ja": "-",
Expand Down Expand Up @@ -242,7 +242,7 @@
{
"name": "operators.md",
"en": "Completed",
"zh-CN": "0b0389f2c@hustcer",
"zh-CN": "fa90895307@hustcer",
"de": "-",
"tr": "-",
"ja": "-",
Expand Down Expand Up @@ -292,7 +292,7 @@
{
"name": "scripts.md",
"en": "Completed",
"zh-CN": "b6c91cabfa@hustcer",
"zh-CN": "fa90895307@hustcer",
"de": "-",
"tr": "-",
"ja": "-",
Expand Down Expand Up @@ -322,7 +322,7 @@
{
"name": "table_of_contents.md",
"en": "Completed",
"zh-CN": "c13a71d11@hustcer",
"zh-CN": "fa90895307@hustcer",
"de": "-",
"tr": "-",
"ja": "-",
Expand All @@ -332,7 +332,7 @@
{
"name": "thinking_in_nushell.md",
"en": "Completed",
"zh-CN": "12fbd8f31c@hustcer",
"zh-CN": "fa90895307@hustcer",
"de": "-",
"tr": "-",
"ja": "-",
Expand Down Expand Up @@ -362,7 +362,7 @@
{
"name": "working_with_lists.md",
"en": "Completed",
"zh-CN": "b6c91cabfa@hustcer",
"zh-CN": "fa90895307@hustcer",
"de": "-",
"tr": "-",
"ja": "-",
Expand Down
16 changes: 12 additions & 4 deletions zh-CN/book/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ _(你可以把 Nushell 的配置加载顺序想象成在启动时执行两行 [R
Nushell 的主要设置是以记录的形式保存在 `config` 环境变量中。这个记录可以用以下方式创建:

```bash
let-env $config = {
let-env config = {
...
}
```

你也可以隐藏(shadow)`$env.config`并更新它:

```bash
let-env $config = ($env.config | upsert <field name> <field value>)
let-env config = ($env.config | upsert <field name> <field value>)
```

按照约定,这个变量被定义在`config.nu`文件中。
Expand All @@ -51,9 +51,9 @@ _(尽管 `$env.config` 是一个环境变量,按照惯例它仍然在 `config.
- `PROMPT_INDICATOR_VI_NORMAL = "〉 "`
- `PROMPT_MULTILINE_INDICATOR = "::: "`

### 使用内置命令
### 使用内置命令进行配置

从 Nushell 0.64 版本开始新增了 2 个内置命令(`config nu` 和 `config env`),凭借这两个命令,你可以使用自定义的编辑器或者 IDE 快速地更改 Nushell 配置信息
从 Nushell 0.64 版本开始新增了两个内置命令(`config nu` 和 `config env`), 通过这两个命令,你可以使用自定义的编辑器或者 IDE 快速地更改 Nushell 配置信息

Nushell 遵循如下的规则来匹配编辑器:

Expand Down Expand Up @@ -94,6 +94,14 @@ Nushell 遵循如下的规则来匹配编辑器:

这样你就可以使用`chsh`命令来将 Nu 设置为你的登录 Shell。在你注销后下次登录时,应该可以看到一个闪亮的 Nu 提示。

### 使用 `login.nu` 进行配置

如果 Nushell 被用作登录 Shell,你可以使用一个特定的配置文件,该文件只在该情况下才会被加载。因此,一个名为 `login.nu` 的文件必须在标准配置目录中。

文件 `login.nu` 的加载在 `env.nu` 和 `config.nu` 之后,所以你可以覆盖这些配置,如果你需要的话。

有一个环境变量 `$nu.loginshell-path` 包含该文件的路径。

### macOS: 保持 `open` 为 `/usr/bin/open`

一些工具(例如 Emacs)依靠`open`命令来打开 Mac 上的文件。
Expand Down
9 changes: 9 additions & 0 deletions zh-CN/book/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ let-env PATH = ($env.PATH | prepend '/path/you/want/to/add')

参见 [模块](modules.md#环境变量) 部分了解更多详情。

## 读取环境变量

单个环境变量是记录的一个字段,存储在 `$env` 变量中,可以用 `$env.VARIABLE` 读取:

```
> $env.FOO
BAR
```

## 作用域

当你设置环境变量时,它将只在当前作用域内可用(变量所在的块和它里面的任何块)。
Expand Down
2 changes: 1 addition & 1 deletion zh-CN/book/loading_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Nu 目前支持直接从以下格式加载表数据:
> open README.md
```

我们会看到该文件的内容,如果文件太大则会得到一个方便的滚动视图来查看文件,然后再跳回终端。为了提高可读性,Nu 还将语法高亮显示常见的文件格式,如源码文件、Markdown 等等
我们会看到该文件的内容。

本质上,这些文本文件对 Nu 来说就是一个大字符串。接下来,我们将讨论如何处理这些字符串,以便从中获得我们需要的数据。

Expand Down
2 changes: 1 addition & 1 deletion zh-CN/book/nushell_map_functional.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
| default | | | | |
| drop | | | | |
| du | | | | |
| each | map, mapv, iterate | map, forEach | map | |
| each | map, mapv, iterate | map, forEach | map, mapM | |
| echo | println | | putStrLn, print | |
| enter | | | | |
| exit | System/exit | | | |
Expand Down
41 changes: 21 additions & 20 deletions zh-CN/book/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@

Nushell 支持以下常见的数学、逻辑和字符串操作的运算符:

| 运算符 | 描述 |
| -------- | --------------------------------- |
| `+` | 加 |
| `-` | 减 |
| `*` | 乘 |
| `/` | 除 |
| `**` | 指数 (幂) |
| `mod` | 取模 |
| `==` | 等于 |
| `!=` | 不等于 |
| `<` | 小于 |
| `<=` | 小于等于 |
| `>` | 大于 |
| `>=` | 大于等于 |
| `=~` | 正则匹配 / 字符串包含另一个字符串 |
| `!~` | 正则不匹配 / 字符串*不*包含另一个 |
| `in` | 列表包含值 |
| `not-in` | 列表不包含值 |
| `&&` | 两个布尔值与运算 |
| `||` | 两个布尔值或运算 |
| 运算符 | 描述 |
| ---------- | --------------------------------- |
| `+` | 加 |
| `-` | 减 |
| `*` | 乘 |
| `/` | 除 |
| `**` | 指数 (幂) |
| `mod` | 取模 |
| `==` | 等于 |
| `!=` | 不等于 |
| `<` | 小于 |
| `<=` | 小于等于 |
| `>` | 大于 |
| `>=` | 大于等于 |
| `=~` | 正则匹配 / 字符串包含另一个字符串 |
| `!~` | 正则不匹配 / 字符串*不*包含另一个 |
| `in` | 列表包含值 |
| `not-in` | 列表不包含值 |
| `not` | 逻辑取反 |
| `&&`, `and`| 两个布尔值与运算 |
| `||`, `or` | 两个布尔值或运算 |

圆括号可用于分组以指定求值顺序,或用于调用命令并在表达式中使用结果。

Expand Down
2 changes: 1 addition & 1 deletion zh-CN/book/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def main [x: int] {
110
```

## Shebangs (`!#`)
## Shebangs (`#!`)

在 Linux 和 macOS 上,你可以选择使用 [Shebang](<https://en.wikipedia.org/wiki/Shebang_(Unix)>)来告诉操作系统一个文件应该被 `Nu` 解释。例如,在一个名为 `myscript` 的文件中包含以下内容:

Expand Down
2 changes: 1 addition & 1 deletion zh-CN/book/working_with_lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ echo "total =" ($scores | math sum) # easier approach, same result

echo "product =" ($scores | reduce --fold 1 { |it, acc| $acc * $it }) # 96

echo $scores | reduce -n { |it, acc| $acc + $it.index * $it.item } # 3 + 1*8 + 2*4 = 19
echo $scores | reduce -n { |it, acc| $acc.item + $it.index * $it.item } # 3 + 1*8 + 2*4 = 19
```

## 访问列表
Expand Down