Skip to content

docs: translate plugin-dev #5345

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 5 commits into from
Jun 22, 2020
Merged

docs: translate plugin-dev #5345

merged 5 commits into from
Jun 22, 2020

Conversation

llccing
Copy link
Contributor

@llccing llccing commented Apr 1, 2020

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Other information:

Copy link
Contributor Author

@llccing llccing left a comment

Choose a reason for hiding this comment

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

翻译了插件开发部分

Copy link
Member

@haoqunjiang haoqunjiang left a comment

Choose a reason for hiding this comment

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

非常感谢翻译!

我读了一遍,基本没什么问题,不过注意到了一些错别字以及提了一些措辞细节上的改进,还烦请修改一下~


- `@vue/cli`:全局安装的,暴露 `vue create <app>` 命令;
- `@vue/cli-service`:局部安装,暴露 `vue-cli-service` 命令。
- 修改项目的 webpack 配置 - 例如,如果你的插件希望去针对某种类型的文件工作,你可以为这个特定的文件扩展名添加新的 webpack 加载规则。你可以看 `@vue/cli-plugin-typescript` 这个插件,添加这样的规则去载入 `.ts` 和 `.tsx` 的扩展文件;
Copy link
Member

Choose a reason for hiding this comment

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

webpack 加载规则

建议翻译为「解析规则」,参考 webpack 官方的中文文档 https://webpack.docschina.org/configuration/resolve/#resolve

你可以看 @vue/cli-plugin-typescript 这个插件,添加这样的规则去载入 .ts.tsx 的扩展文件;

这段读起来有点不顺。改成「比如说,@vue/cli-plugin-typescript 就添加了这样的规则来解析 .ts.tsx 扩展的文件」会不会更好一点?

- `@vue/cli-service`:局部安装,暴露 `vue-cli-service` 命令。
- 修改项目的 webpack 配置 - 例如,如果你的插件希望去针对某种类型的文件工作,你可以为这个特定的文件扩展名添加新的 webpack 加载规则。你可以看 `@vue/cli-plugin-typescript` 这个插件,添加这样的规则去载入 `.ts` 和 `.tsx` 的扩展文件;
- 添加新的 vue-cli-service 命令 - 例如,`@vue/cli-plugin-unit-jest` 添加了 `test:unit` 命令,允许开发者运行单元测试;
- 扩展 `package.json` - 当你的插件添加了一些依赖到项目中,你需要将他们添加到package 的 dependencies 部分时,这是一个有用的选项;
Copy link
Member

Choose a reason for hiding this comment

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

package 前面漏了个空格

Suggested change
- 扩展 `package.json` - 当你的插件添加了一些依赖到项目中,你需要将他们添加到package 的 dependencies 部分时,这是一个有用的选项;
- 扩展 `package.json` - 当你的插件添加了一些依赖到项目中,你需要将他们添加到 package 的 dependencies 部分时,这是一个有用的选项;


CLI 插件是一个可以为 `@vue/cli` 项目添加额外特性的 npm 包。它应该始终包含一个 [Service 插件](#service-插件)作为其主要导出,且可选的包含一个 [Generator](#generator) 和一个 [Prompt 文件](#第三方插件的对话)。
对于一个能够在 Vue CLI 项目中使用的 CLI 插件来说,他必须以下的命名惯例 `vue-cli-plugin-<name>` 或者 `@scope/vue-cli-plugin-<name>`。这样你的插件就能够:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
对于一个能够在 Vue CLI 项目中使用的 CLI 插件来说,他必须以下的命名惯例 `vue-cli-plugin-<name>` 或者 `@scope/vue-cli-plugin-<name>`。这样你的插件就能够
为了让一个 CLI 插件在 Vue CLI 项目中被正常使用,它必须遵循 `vue-cli-plugin-<name>` 或者 `@scope/vue-cli-plugin-<name>` 这样的命名惯例。这样你的插件才能够


:::warning Warning
确保插件的名字是正确的,否则他将不能通过 `vue add` 安装并且不能在 UI 插件中搜索的到!
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
确保插件的名字是正确的,否则他将不能通过 `vue add` 安装并且不能在 UI 插件中搜索的到
确保插件的名字是正确的,否则他将不能通过 `vue add` 安装并且不能在 UI 插件中搜索得到

├── index.js # service 插件
└── package.json

你应该在 `homepage` 或者 `repository` 字段添加创建插件的官网地址或者仓库的地址,这样 `更多信息` 的按钮将展示你的插件描述信息:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
你应该在 `homepage` 或者 `repository` 字段添加创建插件的官网地址或者仓库的地址,这样 `更多信息` 的按钮将展示你的插件描述信息
你应该在 `homepage` 或者 `repository` 字段添加创建插件的官网地址或者仓库的地址,这样你的插件详情里就会出现一个 `查看详情` 按钮

```

#### 第三方插件的对话
上面这个例子中,我们定义值为 '白色' 的输入对话。这就是我们的配置页面如何找到上面提供的所有配置:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
上面这个例子中,我们定义值为 '白色' 的输入对话。这就是我们的配置页面如何找到上面提供的所有配置
上面这个例子中,我们定义值为 'white' 的输入对话。加了以上所有设置后,我们的配置页面看起来会是这样的

一个带有为本仓库注入额外依赖的 generator 的插件 (比如 `chai` 会通过 `@vue/cli-plugin-unit-mocha/generator/index.js` 被注入) 应该将这些依赖列入其自身的 `devDependencies` 字段。这会确保:
你可以看见,在配置页面中 `white` 被 `black` 替换了。

我们可以提供一个默认值,如果配置文件不存在:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
我们可以提供一个默认值,如果配置文件不存在:
如果配置文件不存在,我们可以提供一个默认值

### Logo

你可以放一个 `logo.png` 文件到文件夹根目录,它将被发布到 npm。将在以下几个地方展示:
- 当搜索插件去安装时
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- 当搜索插件去安装时
- 在搜索要安装的插件时


### 发布插件到 npm

为了发布插件,你需要在 [npmjs.com](npmjs.com) 上注册并且全局安装 `npm`。如果这是你的第一个发布的 npm 模块,请执行
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
为了发布插件,你需要在 [npmjs.com](npmjs.com) 上注册并且全局安装 `npm`。如果这是你的第一个发布的 npm 模块,请执行
为了发布插件,你需要在 [npmjs.com](https://www.npmjs.com) 上注册并且全局安装 `npm`。如果这是你的第一个发布的 npm 模块,请执行

输入你的名字和密码。这将存储你的凭证,这样你就不必每次发布时都输入。

:::tip
发布插件之前,确保你为它选择了正确的名字!名字转换是 `vue-cli-plugin-<name>`。在 [Discoverability](#discoverability) 查看更多信息
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
发布插件之前,确保你为它选择了正确的名字!名字转换是 `vue-cli-plugin-<name>`。在 [Discoverability](#discoverability) 查看更多信息
发布插件之前,确保你为它选择了正确的名字!名字规范是 `vue-cli-plugin-<name>`。在 [Discoverability](#discoverability) 查看更多信息

Copy link
Member

@haoqunjiang haoqunjiang left a comment

Choose a reason for hiding this comment

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

还剩了几处小细节没改过来,我直接帮你改掉了吧。然后文档 PR 是要指向 master 分支的,这个一并改掉了。

再次感谢!

@haoqunjiang haoqunjiang changed the base branch from dev to master June 22, 2020 02:48
@haoqunjiang haoqunjiang merged commit dc2456e into vuejs:master Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants