-
-
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(core/view.md): translation #1577
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1577 +/- ##
=======================================
Coverage 99.58% 99.58%
=======================================
Files 29 29
Lines 729 729
=======================================
Hits 726 726
Misses 3 3 Continue to review full report at Codecov.
|
hey, since we just update this docs for 2.x, so sorry for that, you need to checkout the newest zh_CN version and compare it. |
@atian25 , thanks for the remind. I will checkout latest zh_CN version |
@atian25 , the translation is done. You can go ahead to review. |
docs/source/en/core/view.md
Outdated
In most cases, we need to fetch data, render with templates, then return to users. | ||
So a view engine is essential. | ||
|
||
[egg-view] is the built-in view solution of Egg.js. |
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.
翻译里面少出现 Egg.js
吧,这句和下面那句可以改为类似: [egg-view] is a built-in plugin to standard multiple view engine usage.
这样的(要改改,语法啥的)
docs/source/en/core/view.md
Outdated
|
||
[egg-view] is the built-in view solution of Egg.js. | ||
It allows more than one view engine to be used in one application. | ||
All view engines are imported as plugins, and they provide the same rendering API interface. |
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.
结合上面那句,看看一起怎么说,这里的原意是,通过 egg-view 的规范化,应用开发者可以用同样的 API 来使用不同的模板引擎。
Due to the benefits of egg-view, developer could use the same API interface to work with different view engine, consistent experience
啥啥啥的... (同样语法要改改)
docs/source/en/core/view.md
Outdated
[egg-view] is the built-in view solution of Egg.js. | ||
It allows more than one view engine to be used in one application. | ||
All view engines are imported as plugins, and they provide the same rendering API interface. | ||
To know more, see [View Plugin](../advanced/view-plugin.md). |
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.
see xxx for more detail.
docs/source/en/core/view.md
Outdated
To know more, see [View Plugin](../advanced/view-plugin.md). | ||
|
||
Take the officially supported View plugin [egg-view-nunjucks] as 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.
take...for example || take ...as an example
docs/source/en/core/view.md
Outdated
``` | ||
|
||
### Register plugin | ||
|
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.
enable plugin会不会好一点
docs/source/en/core/view.md
Outdated
|
||
### root {String} | ||
|
||
Root directory for template files. It's absolute path. Default value is `${baseDir}/app/view`. |
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.
这个觉得不用断句了,直接 Root directory for template files is an absolute path
docs/source/en/core/view.md
Outdated
Multiple directories, separated by `,`, are supported. | ||
[egg-view] looks for template files from all the directories. | ||
|
||
Below is an example of configuring multiple `view` directories: |
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.
below是一个副词,建议这样用 the configuration below is an example of multiple view
directories
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 configuration below"肯定是更书面更稳妥的表达,已按此提交修改。但其实"the above is", "the following is"都是常见用法: https://english.stackexchange.com/questions/172709/the-above-is-correct-the-below-is-not
docs/source/en/core/view.md
Outdated
Cache template file paths, default value is `true`. | ||
[egg-view] looks for template files from the directories that defined in `root`. | ||
If a matching is found, the file path will be cached. | ||
The next time the same path is used, |
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 file path matched will be cached and be reused while rendering the same path next time
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.
已改成整句。不过我又把它写的冗长了点When a file matching given template path is found, the full file path will be cached and be reused when rendering the same template path afterward
。因为我觉得"template path"和"full file path"值得区分一下,后者是包含了view root directory的绝对路径,因此才有cache的意义。如果是把"home.nj"本身cache起来,显然莫名其妙
docs/source/en/core/view.md
Outdated
[egg-view] provides three interfaces in Context. | ||
All three returns a Promise: | ||
|
||
- `render(name, locals)` renders template file, and set to value to `ctx.body`. |
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.
set to -> set
docs/source/en/core/view.md
Outdated
|
||
- `app.locals` is global, usually configured in `app.js`. | ||
- `ctx.locals` is per-request, and it merges `app.locals`. | ||
- set `ctx.locals` with a new object, [egg-view] auto merges the new object into the previous object using setter. |
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.
最新的中文文档是:可以直接赋值对象,框架在对应的 setter 里面会自动 merge。下面这样翻译是不是好一点:
The object can be assigned directly, and[egg-view] will automatically merge in the corresponding setter
docs/source/en/core/view.md
Outdated
console.log(ctx.locals); // { a: 1, b: 2, c: 3, d: 4 } | ||
``` | ||
|
||
In real development, we usually don't directly use these two objects in controller. |
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.
real感觉不太好,directly放在句尾好一点
docs/source/en/core/view.md
Outdated
Instead, simply call `ctx.render(name, data)`: | ||
- [egg-view] auto merges `data` into `ctx.locals`. | ||
- [egg-view] auto injects `ctx`, `request`, `helper` into locals for your convenience. | ||
|
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.
这里的 auto 改为 automatically 会不会好一点,然后放在句尾
docs/source/en/core/view.md
Outdated
|
||
## Security | ||
|
||
The built-in plugin [egg-security] provides common security related functions, including `helper.shtml / surl / sjs` and so on. You're strongly recommended to read [Security](./security.md). |
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.
You're strongly recommended to read 被字句改为下面的句型:
It is strongly recommended to read [Security]
@atian25 , @SunShinewyf , 谢谢两位的审阅。之前完全是根据中文文档直译的,几处过于生硬。除了你们的意见,我也补充了个别修改,主要是我自己在读中文文档时就觉得描述不够准确的地方。详见da22e29 |
@zhang-z rebase 下 push -f |
da22e29
to
ccb72c9
Compare
@atian25 , rebase done |
docs/source/en/core/view.md
Outdated
|
||
In most cases, we need to fetch data, render with templates, then return to users. | ||
So a view engine is essential. | ||
|
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 need to fetch data and render the templates
最新的中文文档是:故我们需要引入对应的模板引擎。所以感觉下一句最好为:So we need to use corresponding view template
docs/source/en/core/view.md
Outdated
In most cases, we need to fetch data, render with templates, then return to users. | ||
So a view engine is essential. | ||
|
||
[egg-view] is a built-in plugin to standardize the way of using view engines. |
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.
standardize-> support,view engines -> multiple view engines,感觉上面的翻译和文档不太相符
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.
这句和下面一句都是按atian的修改意见稍加改动。#1577 (review)
我觉得两者都可以。你看用哪个?
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.
但是中文文档是这样的:框架内置 egg-view 作为模板解决方案,并支持多模板渲染,你的翻译里面没有“支持多模板渲染“,加上就ok了
docs/source/en/core/view.md
Outdated
So a view engine is essential. | ||
|
||
[egg-view] is a built-in plugin to standardize the way of using view engines. | ||
With [egg-view] developers can use the same API interface to work with different view engines in one application. |
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.
最新中文是:每个模板引擎都以插件的方式引入,但保持渲染的 API 一致。
感觉翻译得有点漏,比如“以插件的方式引入好像没有翻译到”
建议:each view engine is introduced with a way like the plugin but uses the same rendered API
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.
这句也是按atian的回复略作修改。我原句是"All view engines are imported as plugins",我觉得会比"a way like the plugin"更好的点,因为模板引擎“是”插件,而不只是“像”插件。你再看看采用哪个表达?
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.
感觉as会好一点
docs/source/en/core/view.md
Outdated
|
||
### root {String} | ||
|
||
Root directory for template files is absolute path. Default value is `${baseDir}/app/view`. |
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.
default value和前面是连起来的,建议改成:Root directory for template files is absolute path,
it's default value is
docs/source/en/core/view.md
Outdated
Root directory for template files is absolute path. Default value is `${baseDir}/app/view`. | ||
Multiple directories, separated by `,`, are supported. | ||
[egg-view] looks for template files from all the directories. | ||
|
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.
这一句读起来怪怪的:建议[egg-view] supports configuring multiple directories,which are separated by ,
, in this way, it will look for template files from all the directories. 这种,不过可以精简一下
docs/source/en/core/view.md
Outdated
|
||
## Security | ||
|
||
The built-in plugin [egg-security] provides common security related functions, including `helper.shtml / surl / sjs` and so on. It's strongly recommended to read [Security](./security.md). |
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.
这里的辅助(related)翻译成helper是不是会好一点
Instead, simply call `ctx.render(name, data)`: | ||
- [egg-view] merges `data` into `ctx.locals` automatically. | ||
- [egg-view] injects `ctx`, `request`, `helper` into locals automatically. | ||
|
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.
我感觉这里的框架不是指egg-view,而是指egg呢
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.
这个确实是egg-view做的, 因为对中文文档的“框架”有疑惑,我翻的时候还特意查过源代码:https://github.com/eggjs/egg-view/blob/master/lib/context_view.js#L103
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.
额,那就是我理解错了,忽略
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.
都行的,因为 egg-view 是内置到 egg 里面的
docs/source/en/core/view.md
Outdated
## Locals | ||
|
||
In the process of rendering pages, | ||
we usually need a variable to hold all information that is used in view template. |
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.
这里的hold改为contain感觉会好一点
docs/source/en/core/view.md
Outdated
|
||
Cache template file paths, default value is `true`. | ||
[egg-view] looks for template files from the directories that defined in `root`. | ||
When a file matching given template path is found, the full file path will be cached |
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.
When a file matching given template path is found,这一句读起来好怪异
the framework will search according to the directories configured by root and won't search the same path which is matched next time
有点长,可以拆解一下
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.
"No files matching path ..." 是挺常见的系统报错吧。你说的怪异是指?
ccb72c9
to
0ee6620
Compare
@SunShinewyf , 已更新。详见0ee6620 |
@atian25 ok了,可以merge了 |
thanks a lot, @zhang-z @SunShinewyf |
docs(core/view.md): translation (#1577)
Checklist
Description of change
Start to work on translation of core/view