-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
docs(middleware.md): translated & proofread 'middleware.md' #784
docs(middleware.md): translated & proofread 'middleware.md' #784
Conversation
Codecov Report
@@ Coverage Diff @@
## master #784 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 28 28
Lines 667 667
=====================================
Hits 667 667 Continue to review full report at Codecov.
|
docs/source/en/basics/middleware.md
Outdated
|
||
## Writing Middleware | ||
|
||
### how to write |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capitalize how
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. commit: fefcbdb
docs/source/en/basics/middleware.md
Outdated
|
||
### how to write | ||
|
||
We begin by writing a simple gzip middleware, to see how to write middleware |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We begin to see how to write a middleware from a simple gzip example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. commit: fefcbdb
docs/source/en/basics/middleware.md
Outdated
|
||
### Configuration | ||
|
||
Usually the middleware has its own configuration. In the framework, a complete middleware is including the configuration process. We agree that a middleware is a separate file placed in `app/middleware` directory, which needs an exports function that take two parameters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a middleware is a file in app/middleware
directory by convention
convention from https://en.wikipedia.org/wiki/Convention_over_configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. commit: fefcbdb
docs/source/en/basics/middleware.md
Outdated
## Importing Middleware in the Application | ||
|
||
We can import customized middleware completely by configuration in the application, and decide their order. | ||
If we need to import the gzip Middleware in the above, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Middleware > middleware
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. commit: fefcbdb
docs/source/en/basics/middleware.md
Outdated
}, | ||
}; | ||
``` | ||
** Note: middleware imported by the framework and plugins are loaded earlier than those imported by the application layer, and the application layer cannot overwrite the default framework middleware. If the application layer imports customized middleware that has the same name with default framework middleware, an error will be raised on starting up. ** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to change layer
to middleware
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change 'application layer' to 'application middleware'?
How about changing 'application layer' to 'application'? Does it make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good!
Anyway, it is not finalized and can be changed at any time though.
Does anyone have other suggestions?
docs/source/en/basics/middleware.md
Outdated
``` | ||
** Note: middleware imported by the framework and plugins are loaded earlier than those imported by the application layer, and the application layer cannot overwrite the default framework middleware. If the application layer imports customized middleware that has the same name with default framework middleware, an error will be raised on starting up. ** | ||
|
||
## The Use of Middleware in Router |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The Use of Middleware in Router
+ Middleware in Router
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. commit: fefcbdb
感觉中文文档可以把引入改为加载,翻译成 import 有点难懂,还是叫 load 比较好。 |
Related issue: eggjs#784
需要在英文文档中修改过来吗?还是说先改中文文档,再改英文文档? |
中英文一起改吧,看看其他人的意见 @dead-horse @atian25 |
都行吧,小的点顺手改也可以,主要还是 focus 翻译上。其他的我们另开 PR 都行。
发自我的 iPhone
… 在 2017年4月21日,17:15,lslxdx ***@***.***> 写道:
@lslxdx commented on this pull request.
In docs/source/en/basics/middleware.md:
> +```
+
+** About Configuration fields and runtime environment configurations, see [Config](./config.md) chapter. **
+
+## Default Framework Middleware
+
+In addition to the application layer middleware is imported, the framework itself and other plug-ins will also import many middleware. All the config fields of these built-in middlewares can be modified by modifying the ones with the same name in the config file, for example [Framework Built-in Plugin](https://github.com/eggjs/egg/tree/master/app/middleware) uses a bodyParser middleware(the framework loader will change the file name separated by delimiters into the camel style), and we can add configs below in `config/config.default.js` to modify the bodyParser:
+
+```js
+module.exports = {
+ bodyParser: {
+ jsonLimit: '10m',
+ },
+};
+```
+** Note: middleware imported by the framework and plugins are loaded earlier than those imported by the application layer, and the application layer cannot overwrite the default framework middleware. If the application layer imports customized middleware that has the same name with default framework middleware, an error will be raised on starting up. **
Good!
Anyway, it is not finalized and can be changed at any time though.
Does anyone have other suggestions?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@lslxdx 在这篇文章里面把中英文都改了好了,其他文章遇到翻译不通顺的地方可以选择性修改。 |
@popomore 好的,晚上改 |
将这篇文档中的'引入'更改为'加载', 这样可以更容易理解 issue: eggjs#784
Change 'import' to 'load' for a better understanding. issue: eggjs#784
Change "Loading Middleware in the Application" to "Using Middleware in the Application"
@popomore IIRC, we discussed the "application layer/middleware" issue days ago(I can't find the discussion URL, sigh), luckily I find a similar expression here just now, for example:
and
So could we use "application-level" as an agreement? |
When we talk about middleware, we have two steps
So I agree using |
Yes, that makes sense and I agree too! |
Is there anything still block this pr, guys? |
@lslxdx can you complete this PR first? |
@popomore I'm stuck on this thread and could you please help me out? All I can see is: Review requiredAt least one approved review is required by reviewers with write access. Learn more. All checks have passed5 successful checks Merging is blockedMerging can be performed automatically with one approved review. What should I do next? |
I think you will update something, maybe I was wrong? |
Aha! Got it and I am on it! |
Use 'application-level' instead of 'application layer' in some cases.
@popomore I make some changes just now and please have a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
'middleware.md' is translated by @lslxdx and proofread by @闷油瓶小张
related issue: #783
Checklist
Affected core subsystem(s)
Description of change
close #783