Skip to content

Commit f7c5c01

Browse files
committed
翻译 snippets.md
1 parent c25f1fa commit f7c5c01

File tree

4 files changed

+57
-55
lines changed

4 files changed

+57
-55
lines changed

en/Tutorial/Language/Snippets.md

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,62 @@
1-
# 代码块
1+
# Snippets
22

3-
## 概述
3+
## Overview
44

5-
代码块是快速开发的利器。简单的敲几个字母,回车,就能生成大段代码。
5+
Snippets are a powerful tool for rapid development. Simply type a few letters and press Enter to generate a large piece of code.
66

7-
比如我们经常会敲if...else结构,在HBuilderX中,只需敲`ife`回车,就能直接生成相应的代码结构。
7+
For example, we often type the `if...else` structure. In HBuilderX, you can directly generate the corresponding code structure by hitting `ife` and enter.
88

9-
`ife`
9+
input `ife`
1010

1111
<img src="/static/snapshots/tutorial/snippets_3.png" style="zoom: 90%;" />
1212

13-
回车后生成if结构体
13+
Generate if structure after carriage return.
1414

1515
<img src="/static/snapshots/tutorial/snippets_4.png" style="zoom: 90%;" />
1616

17-
## 常用代码块列表
17+
## List of commonly used code blocks
1818

19-
**通用js代码块**
19+
**JavaScript Snippets**
2020

21-
- iff :简单if
22-
- forr :for循环结构体
23-
- fori :for循环结构体并包含i
24-
- funn:函数
25-
- funa:匿名函数
26-
- clog:打印日志
27-
- clogvar:打印变量命名和值
21+
- iff
22+
- forr :for loop structure
23+
- fori :for loop structure and contains i
24+
- funn: function
25+
- funa: anonymous function
26+
- clog: print log
27+
- clogvar: print variable name and value
2828

29-
**dom代码块**
29+
**dom Snippets**
3030

3131
- dg :document.getElementById
3232
- dl :$("")
3333

34-
**vue代码块**
34+
**vue Snippets**
3535

36-
敲v,即可拉出各种vue代码块
36+
Enter `v`, You can pull out various vue Snippets.
3737

38-
**uni-app代码块**
38+
**uni-app Snippets**
3939

40-
敲u,即可拉出各种uni-app代码块
41-
还有ifios、ifandroid,这2个平台判断代码块(HBuilderX 1.9.10+)
40+
Enter `u`, You can pull out various uniapp Snippets.
4241

43-
## 代码块设置
42+
## Snippets settings
4443

45-
HBuilderX已经内置了大量常用的代码块,熟悉这些代码块,对于提高编程效率有重要帮助。
44+
HBuilderX has built-in a large number of commonly used Snippets. Familiarity with these Snippets is important to improve programming efficiency.
4645

47-
查看内建的代码块,点击菜单-工具-代码块设置,选择你要查看的语言的代码块。
46+
To view the built-in Snippets, click [Menu-Tools-Snippets Settings], and select the Snippets of the language you want to view.
4847

49-
<img src="/static/snapshots/tutorial/snippets_1.png" style="zoom: 90%;" />
48+
<img src="/static/snapshots/tutorial/menu_tool/menu_snippets_en.png" class="hd-img" />
5049

51-
打开的界面中,左侧即是预置的代码块,右侧是开发者可以自己扩展代码块的地方。
50+
In the opened interface, the left side is the preset Snippets, and the right side is the place where developers can extend the Snippets by themselves.
5251

53-
<img src="/static/snapshots/tutorial/snippets_2.png" style="zoom: 80%;" />
52+
<img src="/static/snapshots/tutorial/menu_tool/snippets_custom_en.png" class="hd-img" />
5453

5554

56-
## 自定义代码块
55+
## Custom Snippets
5756

58-
自定义代码块都是配置json文件中的,直接来一个js例子吧,上述`ife`代码块的配置如下:
57+
Custom Snippets are in the configuration json file.
58+
59+
js Snippets example: the configuration of the above `ife` Snippets is as follows:
5960

6061
```json
6162
{
@@ -73,50 +74,50 @@ HBuilderX已经内置了大量常用的代码块,熟悉这些代码块,对
7374
}
7475
```
7576

76-
### 代码块配置格式说明
77+
### Snippets Format description
7778

78-
HBuilderX使用json定义代码块的格式,兼容vscode的代码块格式,也就是你可以把vscode里已经配置的自定义代码块方便的挪到HBuilderX中使用。
79+
HBuilderX uses json to define the format of the Snippets, which is compatible with the Snippets format of vscode, that is, you can easily move the custom Snippets that has been configured in vscode to HBuilderX for use.
7980

8081

81-
|配置项 |说明 |
82-
|-- |-- |
83-
|key |代码块显示名称,显示在代码助手列表中的名字。key是不能重复的。上面例子中`"if ... else"`就是一个`key` |
84-
|prefix |代码块的触发字符,就是敲什么字母可以激活这个代码块。 |
85-
|body |代码块的内容 |
86-
|triggerAssist |`true`表示该代码块输入到文档后立即在第一个`tabstop`上触发代码提示,拉出代码助手,默认为`false` |
87-
| project |将代码块控制在指定项目类型下生效。可取值有:`uni-app``Web``App``Wap2App`<br/>`Web`指普通项目,`App`指5+App项目。如果不设置,则该代码块在所有项目类型下均生效。<br/>比如:`"project": "uni-app"`,代表这个代码块仅在uni-app项目下生效。<br/>如需设置多种项目类型,用逗号分隔。比如:`"project": "uni-app,App"` |
82+
|Configuration item |Description |
83+
|-- |-- |
84+
|key |Snippets display name, the name displayed in the code assistant list. The key cannot be repeated.|
85+
|prefix |Trigger character of Snippets |
86+
|body |The content of the Snippets. |
87+
|triggerAssist |True means that the code prompt is triggered on the first tabtop immediately after the code block is entered into the document, and the code assistant is pulled out. The default is false. |
88+
|project |Control the code block to take effect under the specified project type. Possible values are: `uni-app`, `Web`, `App`, `Wap2App`.<br/>To set multiple item types, separate them with commas. For example: `"project": "uni-app,App"` |
8889

89-
**配置项body详细说明:**
90+
**Body description:**
9091

91-
- `$1` 表示代码块输入后光标的所在位置。如需要多光标,就在多个地方配置`$1`;如该位置有预置数据且需要选中,则写法是`${1:selectedtext}`;这里还支持下拉候选菜单,多选项即下拉候选列表使用`${1:foo1/foo2/foo3}`
92-
- `$2` 表示代码块输入后再次按tab后光标的切换位置`tabstops`(代码块展开后按tab可以跳到下一个`tabstop`,在HBuilderX中看到类似绿色光标的不闪的竖线,就可以按tab或回车跳转光标过去)
93-
- `$0`代表代码块输入后最终光标的所在位置(也可以按回车直接跳过去)。
92+
- `$1` The position of the cursor after the code block is entered. If you need multiple cursors, configure `$1` in multiple places; if there are preset data at this location and need to be selected, the writing method is `${1:selectedtext}`; here also supports drop-down candidate menus, multiple options are drop-down candidates The list uses `${1:foo1/foo2/foo3}`
93+
- `$2` After the code block is entered, the cursor switch position after pressing tab again.
94+
- `$0` The final cursor position after the code block is entered.
9495

95-
特别说明
96-
1. **双引号使用`\"`转义**
97-
2. **换行使用多个数组表示,每个行一个数组,用`双引号`包围,并用`逗号`分隔**
98-
3. **缩进需要用`\t`表示,不能直接输入缩进或空格!**
96+
Remark
97+
1. **Double quotes are escaped with `\"`**
98+
2. **Line breaks are represented by multiple arrays, one array per line, surrounded by `double quotes` and separated by `commas`**
99+
3. **The indentation needs to be indicated by `\t`, you cannot directly enter the indentation or spaces! **
99100

100101

101-
### 注意事项
102+
### Matters needing attention
102103

103-
1. 每个代码块以`key`为主键,多个代码块需要`逗号`分隔。
104-
2. 如果json语法不合法,编辑器状态栏会弹出错误信息,json中会画出红波浪线,请注意修正。
104+
1. Each code block uses `key` as the main key, and multiple code blocks need to be separated by `commas`.
105+
2. If the json syntax is illegal, an error message will pop up in the editor status bar, and a red wavy line will be drawn in the json, please pay attention to the correction.
105106

106-
## 注释模板同步时间
107+
## Comment template For Datetime
107108

108-
> HBuilderX 2.7.5+版本起,支持主持注释模板同步时间
109+
> From HBuilderX 2.7.5+ version, it supports the synchronization time of host annotation template
109110
110-
点击菜单【工具】【代码块设置】【javascript代码块】,输入如下内容:
111+
Click the menu [Tools - Snippets settings - javascript snippets], and enter the following:
111112

112113
```
113114
{
114115
"method-annotation": {
115116
"prefix": "anno",
116117
"body": [
117118
"/**",
118-
" * 方法说明",
119-
" * author: 佚名",
119+
" * Method description",
120+
" * author: author name",
120121
" * description: ",
121122
" * @param $1",
122123
" * @return $2",

en/_sidebar.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
* [External Commands](/Tutorial/UserGuide/externalCommands.md)
3030
* Languages
3131
* [Overview](/Tutorial/Language/Overview.md)
32-
* [CodeAssistant](/Tutorial/Language/CodeAssistant.md)
32+
* [CodeAssistant](/Tutorial/Language/CodeAssistant.md)
33+
* [Snippets](/Tutorial/Language/Snippets.md)
3334
* [Emmet](/Tutorial/Language/emmet)
3435
* [Vue](/Tutorial/Language/vue.md)
3536
* [Vue3](/Tutorial/Language/vue-next.md)
72.9 KB
Loading
145 KB
Loading

0 commit comments

Comments
 (0)