Skip to content

Commit

Permalink
Update: translations
Browse files Browse the repository at this point in the history
  • Loading branch information
AmosHuKe committed Mar 9, 2024
1 parent 19d7b55 commit 3390e76
Show file tree
Hide file tree
Showing 37 changed files with 329 additions and 160 deletions.
2 changes: 1 addition & 1 deletion src/_data/side-nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
- title: Flutter
permalink: https://flutter.cn
- title: Package 网站
permalink: https://pub.flutter-io.cn
permalink: https://pub-web.flutter-io.cn/

- title: 关于 Dart 中文文档
expanded: false
Expand Down
2 changes: 1 addition & 1 deletion src/_includes/navigation-toc-side.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% if tocContents.count > 1 -%}
<div id="site-toc--side" class="site-toc">
<header class="site-toc__title">
Contents
目录
</header>
<ul class="section-nav">
{% for topLevel in tocContents.toc %}
Expand Down
2 changes: 1 addition & 1 deletion src/_includes/navigation-toc-top.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{% endif -%}
<div id="site-toc--inline" class="site-toc{{topStyle}}">
<header class="site-toc__title">
Contents
目录
{% if collapsible %}
<span class="site-toc--inline__toggle toc-toggle-down"><i class="material-symbols">keyboard_arrow_down</i></span>
<span class="site-toc--inline__toggle toc-toggle-up"><i class="material-symbols">keyboard_arrow_up</i></span>
Expand Down
2 changes: 1 addition & 1 deletion src/_includes/page-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% if obsolete == true -%}
<div class="alert alert-warning">
<h4 class="text-center">
Some of the content of this page might be out of date.
本页面的部分内容可能已经过时。
</h4>
</div>
{% endif -%}
Expand Down
6 changes: 3 additions & 3 deletions src/_includes/pub-problems.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
:::note
:::note 有疑问?
<!-- Problems? -->

*Problems?*
Check out the [Troubleshooting pub](/tools/pub/troubleshoot) guidelines.

**有疑问?** 请查阅 [Pub 疑难协助](/tools/pub/troubleshoot)
请查阅 [Pub 疑难协助](/tools/pub/troubleshoot)

:::
2 changes: 1 addition & 1 deletion src/_layouts/default.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="zh">
{% include 'head.html' %}
{% if toc != false -%}
{% assign tocContents = content | generate_toc %}
Expand Down
2 changes: 1 addition & 1 deletion src/_layouts/error.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="zh">
{% include 'head.html' %}
<body class="{{layout}} hide_toc">
<!-- {% include 'cookie-notice.html' %} -->
Expand Down
2 changes: 1 addition & 1 deletion src/_layouts/homepage.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="zh">
{% include 'head.html' %}
<body class="homepage">
<!-- {% include 'cookie-notice.html' %} -->
Expand Down
10 changes: 5 additions & 5 deletions src/content/articles/libraries/creating-streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ You can also pause while listening or stop listening to the stream
before it is complete.

dart:async 库中有两个类型,它们对许多 Dart API 来说都非常重要:
[Stream]({{site.dart_api}}/{{site.data.pkg-vers.SDK.channel}}/dart-async/Stream-class.html)
[Future]({{site.dart_api}}/{{site.data.pkg-vers.SDK.channel}}/dart-async/Future-class.html)
[Stream]({{site.dart-api}}/{{site.data.pkg-vers.SDK.channel}}/dart-async/Stream-class.html)
[Future]({{site.dart-api}}/{{site.data.pkg-vers.SDK.channel}}/dart-async/Future-class.html)
Future 用于表示单个运算的结果,而 Stream 则表示多个结果的序列。
你可以监听 Stream 以获取其结果(包括数据和错误)或其关闭事件。
也可以在 Stream 完成前对其暂停或停止监听。
Expand Down Expand Up @@ -175,7 +175,7 @@ transformers provided by the dart:convert library.
通常而言,使用各种转换方法足以满足你简单的使用需求。
但是,如果你需要对转换进行更多的控制,
你可以使用 `Stream` 类的 `transform()` 方法指定一个
[StreamTransformer]({{site.dart_api}}/{{site.data.pkg-vers.SDK.channel}}/dart-async/StreamTransformer-class.html)
[StreamTransformer]({{site.dart-api}}/{{site.data.pkg-vers.SDK.channel}}/dart-async/StreamTransformer-class.html)
Dart 平台库为许多常见的任务需求提供了 Stream 转换器。
例如下面的代码使用了由 dart:convert 库提供的
`utf8.decoder``LineSplitter` 转换器。
Expand Down Expand Up @@ -319,7 +319,7 @@ to create and populate the stream.
如果你 Stream 的事件不仅来自于异步函数可以遍历的 Stream 和 Future,
还来自于你程序的不同部分,这种情况使用上述两种方式生成 Stream 就显得比较困难。
面对这种情况,我们可以使用一个
[StreamController]({{site.dart_api}}/{{site.data.pkg-vers.SDK.channel}}/dart-async/StreamController-class.html)
[StreamController]({{site.dart-api}}/{{site.data.pkg-vers.SDK.channel}}/dart-async/StreamController-class.html)
来创建和填充 Stream。

A `StreamController` gives you a new stream
Expand Down Expand Up @@ -623,7 +623,7 @@ keep these tips in mind:
使用同步控制器时要小心。
例如,使用 `StreamController(sync: true)` 构造方法创建控制器。
当你发送一个事件到一个未暂停的同步控制器
(例如:使用 [EventSink]({{site.dart_api}}/{{site.data.pkg-vers.SDK.channel}}/dart-async/EventSink-class.html)
(例如:使用 [EventSink]({{site.dart-api}}/{{site.data.pkg-vers.SDK.channel}}/dart-async/EventSink-class.html)
中定义的 `add()``addError()``close()` 方法),
事件立即发送给所有 Stream 的监听器。
在添加监听器的代码返回之前,决不能调用 `Stream` 监听器,
Expand Down
8 changes: 3 additions & 5 deletions src/content/codelabs/dart-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ clicking the **Run** button. The editors also contain thorough test code;

在这篇 codelab 中的嵌入式编辑器已经完成了部分代码片段。
你可以在这些编辑器上将代码补充完整,然后点击 **Run (运行)** 按钮进行测试。
如果你需要帮助,请点击 **Hint (提示)** 按钮。
要运行代码格式化 ([dart format](/tools/dart-format)),
点击 **Format (格式化)** 按钮,**Reset (重置)** 按钮将会清除你的操作,
并把编辑器恢复到初始状态。
这些编辑器上还包含了健全的测试代码;
你可以随时研究这些代码来学习测试方面的知识,但 **不要编辑测试代码**

:::note

Expand Down Expand Up @@ -1783,7 +1781,7 @@ before the constructor body executes.
Do this work in an initializer list,
which goes between the constructor's signature and its body:

有时,当你在实现构造函数时,您需要在构造函数体执行之前进行一些初始化
有时,当你在实现构造函数时,你需要在构造函数体执行之前进行一些初始化
例如,final 修饰的字段必须在构造函数体执行之前赋值。
在初始化列表中执行此操作,该列表位于构造函数的签名与其函数体之间:

Expand Down
4 changes: 2 additions & 2 deletions src/content/effective-dart/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ to [initialize the field at its declaration][init at decl].
有时实例的某些字段在被初始化后不会再变化,但只能在实例被构造后才能被初始化。
例如,某些字段可能需要引用 `this`
在这种情况下,请考虑将其声明为 `late final` 形式。
当这样声明后,您也许可以 [在声明时完成初始化][init at decl]
当这样声明后,你也许可以 [在声明时完成初始化][init at decl]

[init at decl]: /effective-dart/usage#do-initialize-fields-at-their-declaration-when-possible

Expand Down Expand Up @@ -2256,7 +2256,7 @@ ensure that the value's runtime type supports the member you want to access
before you access it.

除此之外,我们建议你使用 `Object?` 或者 `Object`,并使用 `is` 来检查和进行类型升级,
以确保在运行时访问判断这个值支持您要访问的成员
以确保在运行时访问判断这个值支持你要访问的成员

<?code-excerpt "design_good.dart (object-vs-dynamic)"?>
```dart tag=good
Expand Down
6 changes: 3 additions & 3 deletions src/content/effective-dart/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Using a doc comment instead of a regular comment enables
[`dart doc`][] to find it
and generate documentation for it.

使用文档注释可以让 [dartdoc][] 来为你生成代码 API 文档。
使用文档注释可以让 [`dart doc`][] 来为你生成代码 API 文档。

<?code-excerpt "docs_good.dart (use-doc-comments)"?>
```dart tag=good
Expand Down Expand Up @@ -265,7 +265,7 @@ This helps you write a tight first sentence that summarizes the documentation.
Also, tools like `dart doc` use the first paragraph as a short summary in places
like lists of classes and members.

这有助于您编写一个紧凑的第一句话来总结文档
这有助于你编写一个紧凑的第一句话来总结文档
此外,像Dartdoc这样的工具使用第一段作为类和类成员列表等地方的简短摘要。

<?code-excerpt "docs_good.dart (first-sentence-a-paragraph)"?>
Expand Down Expand Up @@ -577,7 +577,7 @@ There are tons of guides out there already to introduce you to Markdown. Its
universal popularity is why we chose it. Here's just a quick example to give you
a flavor of what's supported:

有很多指南已经向您介绍Markdown。 它普遍受欢迎是我们选择它的原因。 这里只是一个简单的例子,让您了解所支持的内容
有很多指南已经向你介绍Markdown。 它普遍受欢迎是我们选择它的原因。 这里只是一个简单的例子,让你了解所支持的内容

<?code-excerpt "docs_good.dart (markdown)"?>
````dart
Expand Down
8 changes: 4 additions & 4 deletions src/content/effective-dart/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ extension SmartIterable<T> on Iterable<T> { ... }
[extensions]: /language/extension-methods

<a id="do-name-libraries-and-source-files-using-lowercase_with_underscores"></a>
<!-- ### DO name packages, directories, and source files using `lowercase_with_underscores` {:#do-name-packages-and-file-system-entities-using-lowercase-with-underscores} -->
### DO name packages, directories, and source files using `lowercase_with_underscores` {:#do-name-packages-and-file-system-entities-using-lowercase-with-underscores}

### ****```package``文件夹``源文件` 中使用 `lowercase_with_underscores` 方式命名 {:#do-name-packages-and-file-system-entities-using-lowercase-with-underscores}
### ****```package``文件夹``源文件` 中使用 `lowercase_with_underscores` 方式命名 {:#要在库,package,文件夹,源文件中使用 lowercase_with_underscores 方式命名}

{% include 'linter-rule-mention.md', rules:'file_names, package_names' %}

Expand Down Expand Up @@ -246,7 +246,7 @@ class Dice {
You may use `SCREAMING_CAPS` for consistency with existing code,
as in the following cases:

您可以使用 `SCREAMING_CAPS` 与现有代码保持一致,比如:
你可以使用 `SCREAMING_CAPS` 与现有代码保持一致,比如:

* When adding code to a file or library that already uses `SCREAMING_CAPS`.

Expand Down Expand Up @@ -648,7 +648,7 @@ whole `if` statement fits on one line, you can omit the braces if you prefer:

这里有一个例外:一个没有 `else``if` 语句,
并且这个 `if` 语句以及它的执行体适合在一行中实现。
在这种情况下,如果您愿意,可以不用括号:
在这种情况下,如果你愿意,可以不用括号:

<?code-excerpt "style_good.dart (one-line-if)"?>
```dart tag=good
Expand Down
8 changes: 4 additions & 4 deletions src/content/effective-dart/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ people.forEach(print);
Also note that it's always OK to use `Map.forEach()`. Maps aren't iterable, so
this guideline doesn't apply.

您可以调用 `Map.forEach()`。Map 是不可迭代的,所以该准则对它无效。
你可以调用 `Map.forEach()`。Map 是不可迭代的,所以该准则对它无效。

### DON'T use `List.from()` unless you intend to change the type of the result

Expand Down Expand Up @@ -1368,7 +1368,7 @@ Treasure? openChest(Chest chest, Point where) => _opened.containsKey(chest)
You can also use `=>` on members that don't return a value. This is idiomatic
when a setter is small and has a corresponding getter that uses `=>`.

您还可以对不返回值的成员使用 `=>`
你还可以对不返回值的成员使用 `=>`
这里有个惯例,就是当 setter 和 getter 都比较简单的时候使用 `=>`

<?code-excerpt "usage_good.dart (arrow-setter)"?>
Expand Down Expand Up @@ -1797,8 +1797,8 @@ The answer is probably "no", in which case you should filter the types you
catch. In most cases, you should have an `on` clause that limits you to the
kinds of runtime failures you are aware of and are correctly handling.

答案和可能是 "no",在这种情况下,您应该过滤掉捕获的类型
在大多数情况下,您应该有一个 `on` 子句,
答案和可能是 "no",在这种情况下,你应该过滤掉捕获的类型
在大多数情况下,你应该有一个 `on` 子句,
这样它能够捕获程序在运行时你所关注的限定类型的异常并进行恰当处理。

In rare cases, you may wish to catch any runtime error. This is usually in
Expand Down
2 changes: 1 addition & 1 deletion src/content/get-dart/archive/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ and the [Dart API documentation.]({{site.dart-api}}/{{site.sdkInfo.channel}})

你可以在此页面下载 [特定版本](/get-dart#release-channels)
[Dart SDK](/tools/sdk)
[Dart API 文档](({{site.dart_api}}/{{site.data.pkg-vers.SDK.channel}}))
[Dart API 文档](({{site.dart-api}}/{{site.data.pkg-vers.SDK.channel}}))

Want to install Dart with your OS's package manager?
[Get Dart.](/get-dart)
Expand Down
2 changes: 1 addition & 1 deletion src/content/guides/language/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The Dart 2 language specification is available in PDF format:

* [Formal specification (Dart 2.10)][2-10 formal spec]

[正式的规范文档 (Dart 2.10 版本)][formal spec]
[正式的规范文档 (Dart 2.10 版本)][2-10 formal spec]

[2-10 formal spec]: /guides/language/specifications/DartLangSpec-v2.10.pdf

Expand Down
20 changes: 11 additions & 9 deletions src/content/guides/libraries/create-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ Package 的最基本要求包括:

pubspec file
<br> The `pubspec.yaml` file for a library is the same
as for an [application package]][]—there is no special
as for an [application package][]—there is no special
designation to indicate that the package is a library.

pubspec 文件
<br> Package 的 `pubspec.yaml` 文件与应用程序的
`pubspec.yaml` 文件相同&mdash; `pubspec.yaml`
<br> Package 的 `pubspec.yaml` 文件与
[应用程序的 `pubspec.yaml` 文件][application package]
相同&mdash; `pubspec.yaml`
文件中并没有特别的指出这个 Package 是一个库。

lib directory
Expand All @@ -84,7 +85,7 @@ lib 目录

[application package]: /tools/pub/glossary#application-package

## Organizing a library package
## Organizing a package

## 组织 Package 的代码结构

Expand Down Expand Up @@ -126,9 +127,10 @@ Some packages have separate libraries that are meant to be imported
with a prefix, when the main library is not.

lib 目录还可能包含其他可导入的非 src 代码。
例如,主 Library 可能是跨平台的,但创建的独立 Library 依赖于 dart:io 或 dart:html
例如,主 Library 可能是跨平台的,
但创建的独立 Library 依赖于 `dart:io``dart:js_interop`
Some packages have separate libraries that are meant to be imported
with a prefix, when the main library is not.(无法确切理解含义,暂未翻译)
with a prefix, when the main library is not.

Let's look at the organization of a real-world package: shelf. The
[shelf](https://github.com/dart-lang/shelf)
Expand Down Expand Up @@ -401,7 +403,7 @@ the [`dart doc`][] tool.
[documentation comments](/effective-dart/documentation#doc-comments),
which use the `///` syntax:

使用 [dartdoc][] 可以为 Library 生成 API 文档。
使用 [`dart doc`][] 可以为 Library 生成 API 文档。
dartdoc 解析源文件去查找使用 `///` 语法标注的
[文档注释](/effective-dart/documentation#doc-comments)

Expand All @@ -426,9 +428,9 @@ For the how-and-why of documenting libraries, see
更多详情,请参阅文档
[Effective Dart: Documentation](/effective-dart/documentation#consider-writing-a-library-level-doc-comment)

<!-- ## Distributing an open source library {:#distributing-a-library} -->
## Distributing an open source library {:#distributing-a-library}

## 分发开源 Library {:#distributing-a-library}
## 分发开源 Library {:#分发开源 Library}

If your library is open source,
we recommend sharing it on the [pub.dev site.]({{site.pub}})
Expand Down
Loading

0 comments on commit 3390e76

Please sign in to comment.