Skip to content

docs(cn): translate src/content/api/loaders.md #755

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

Closed
wants to merge 1 commit into from

Conversation

alvin-xin
Copy link

@alvin-xin alvin-xin commented Jun 15, 2020

翻译 API/Loader Interface 部分文档

@QC-L @dear-lizhihua @yuqingc

@netlify
Copy link

netlify bot commented Jun 15, 2020

Deploy preview for cn-webpack ready!

Built with commit c13edee

https://deploy-preview-755--cn-webpack.netlify.app

@alvin-xin alvin-xin changed the title docs(cn): translate https://github.com/docschina/webpack.js.org/blob/… docs(cn): translate src/content/api/loaders.md Jun 15, 2020
@alvin-xin alvin-xin closed this Jun 17, 2020
@alvin-xin alvin-xin reopened this Jun 17, 2020
@alvin-xin alvin-xin closed this Jun 17, 2020
@lcxfs1991
Copy link

这个怎么closed了

@alvin-xin alvin-xin reopened this Jun 17, 2020
@alvin-xin
Copy link
Author

alvin-xin commented Jun 17, 2020

这个怎么closed了

之前没添加Reviewers,找了一圈没有找到怎么添加,直接Reopen吧


T> Loaders may be added inline in requests and disabled via inline prefixes, which will impact the order in which they are "pitched" and executed. See [`Rule.enforce`](/configuration/module/#ruleenforce) for more details.
module.exports = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是复制多了,还是删少了...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该是一不小心加进来的

@QC-L
Copy link
Member

QC-L commented Jun 18, 2020

认真核对下中英文,建议查看 Files Change

Copy link
Member

@QC-L QC-L left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请尽快修改

@QC-L QC-L mentioned this pull request Jun 26, 2020
49 tasks
@lcxfs1991
Copy link

@Aastasia 请尽快修改

@dear-lizhihua
Copy link

dear-lizhihua commented Sep 1, 2020

在翻译的时候,建议恢复 `xxx` 左右的 ` 符号,这是 markdown 提供的高亮颜色

@dear-lizhihua dear-lizhihua self-requested a review September 1, 2020 05:15

``` diff
|- a-loader `pitch`
|- b-loader `pitch` returns a module
|- a-loader normal execution
```

See the [bundle-loader](https://github.com/webpack-contrib/bundle-loader) for a good example of how this process can be used in a more meaningful way.
查看 [bundle-loader](https://github.com/webpack-contrib/bundle-loader) 了解如何以更有意义的方式使用此过程。


## The Loader Context

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Loader Context 改为 loader context


Given the following example, this require call is used:
下面提供一个例子,将使用 require 进行调用:

In `/abc/file.js`:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In /abc/file.js:
/abc/file.js 中:


在我们的例子中:因为 resource.js 在这个目录中,这个属性为 /abc

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

严格点应该说:这个属性的值为 /abc


T> Since webpack 5, `this.getOptions` is available in loader context. It substitutes `getOptions` method from [loader-utils](https://github.com/webpack/loader-utils#getoptions).

提取给定的 loader 选项,接受一个可选的 JSON 格式化对象作为参数

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON schema 不需要翻译

@@ -282,6 +273,7 @@ loaders = [{request: string, path: string, query: string, module: function}]
```

In the example:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这行应该删除

@@ -649,8 +626,8 @@ module.exports = function(source) {

## Logging

Logging API is available since the release of webpack 4.37. When `logging` is enabled in [`stats configuration`](/configuration/stats/#statslogging) and/or when [`infrastructure logging`](/configuration/other-options/#infrastructurelogging) is enabled, loaders may log messages which will be printed out in the respective logger format (stats, infrastructure).
自webpack 4.37发布以来,日志API就可用了。当 [`stats configuration`](/configuration/stats/#statslogging) 或者 [`infrastructure logging`](/configuration/other-options/#infrastructurelogging) 开启 logging 时,加载程序可以记录消息,这些消息将以相应的日志格式(statsinfrastructure)打印出来。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加载程序 => loader

- Loaders should prefer to use `this.getLogger()` for logging which is a shortcut to `compilation.getLogger()` with loader path and processed file. This kind of logging is stored to the Stats and formatted accordingly. It can be filtered and exported by the webpack user.
- Loaders may use `this.getLogger('name')` to get an independent logger with a child name. Loader path and processed file is still added.
- Loaders may use special fallback logic for detecting logging support `this.getLogger() ? this.getLogger() : console` to provide a fallback when an older webpack version is used which does not support `getLogger` method.
- Loaders 最好使用 this.getLogger() 用于日志记录,这是指向 compilation.getLogger() 具有加载程序路径和已处理的文件。这种日志记录被存储到Stats中并相应地格式化。它可以被webpack用户过滤和导出。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加载程序 => loader

- Loaders may use `this.getLogger('name')` to get an independent logger with a child name. Loader path and processed file is still added.
- Loaders may use special fallback logic for detecting logging support `this.getLogger() ? this.getLogger() : console` to provide a fallback when an older webpack version is used which does not support `getLogger` method.
- Loaders 最好使用 this.getLogger() 用于日志记录,这是指向 compilation.getLogger() 具有加载程序路径和已处理的文件。这种日志记录被存储到Stats中并相应地格式化。它可以被webpack用户过滤和导出。
- Loaders 可以使用 this.getLogger("name") 获取具有子名称的独立记录器。仍会添加加载程序路径和已处理的文件。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加载程序 => loader

- Loaders may use `this.getLogger('name')` to get an independent logger with a child name. Loader path and processed file is still added.
- Loaders may use special fallback logic for detecting logging support `this.getLogger() ? this.getLogger() : console` to provide a fallback when an older webpack version is used which does not support `getLogger` method.
- Loaders 最好使用 this.getLogger() 用于日志记录,这是指向 compilation.getLogger() 具有加载程序路径和已处理的文件。这种日志记录被存储到Stats中并相应地格式化。它可以被webpack用户过滤和导出。
- Loaders 可以使用 this.getLogger("name") 获取具有子名称的独立记录器。仍会添加加载程序路径和已处理的文件。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

记录器 => logger

- Loaders may use special fallback logic for detecting logging support `this.getLogger() ? this.getLogger() : console` to provide a fallback when an older webpack version is used which does not support `getLogger` method.
- Loaders 最好使用 this.getLogger() 用于日志记录,这是指向 compilation.getLogger() 具有加载程序路径和已处理的文件。这种日志记录被存储到Stats中并相应地格式化。它可以被webpack用户过滤和导出。
- Loaders 可以使用 this.getLogger("name") 获取具有子名称的独立记录器。仍会添加加载程序路径和已处理的文件。
- Loaders 可以使用特殊的回退逻辑来检测日志支持 this.getLogger() ? this.getLogger() : console。 在使用不支持 getLogger 方法的旧webpack版本时提供回退选项。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

提供回退选项 => 提供回退方法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants