-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy path2020-05-12-native-command-mode-tools.adoc.po
237 lines (202 loc) · 18.9 KB
/
2020-05-12-native-command-mode-tools.adoc.po
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# SOME DESCRIPTIVE TITLE
# Copyright (C) YEAR Free Software Foundation, Inc.
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2022-05-12 15:52+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. type: YAML Front Matter: title
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy, no-wrap
msgid "Ideas on Quarkus command-mode, UI-based apps and releasing via GitHub Actions"
msgstr "关于Quarkus命令模式、基于UI的应用程序和通过GitHub行动发布的想法"
#. type: YAML Front Matter: synopsis
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy, no-wrap
msgid "Ideas on how to use Quarkus command-mode to develop native applications with web frontends; built with GitHub Actions."
msgstr "关于如何使用Quarkus命令模式来开发具有Web前端的本地应用程序的想法;使用GitHub Actions构建。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "Quarkus is advertised as a cloud-native runtime for Microservices but the link:https://quarkus.io/blog/quarkus-1-4-final-released/[introduction of command-mode] might have opened up new and interesting spaces where it could find adoption."
msgstr "Quarkus被宣传为微服务的云原生运行时,但 link:https://quarkus.io/blog/quarkus-1-4-final-released/[命令模式的引入] 可能开辟了新的、有趣的空间,在那里它可以找到应用。"
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid ""
"In this blog post I will present a few ideas about the possible usage of command-mode in Quarkus that you might find useful to consider when developing your next tool.\n"
"If you have not heard about command-mode, I suggest to start reading link:https://quarkus.io/blog/introducing-command-mode/[this introduction] first and then come back."
msgstr "在这篇博文中,我将介绍 Quarkus 中可能使用的命令模式的一些想法,你在开发下一个工具时可能会发现这些想法很有用。如果你还没有听说过命令模式,我建议你先阅读 link:https://quarkus.io/blog/introducing-command-mode/[这篇介绍] ,然后再回来。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "Ready? Ok, let's continue."
msgstr "准备好了吗?好的,让我们继续。"
#. type: Title ==
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy, no-wrap
msgid "Cross-platform builds via GitHub Actions"
msgstr "通过GitHub Actions进行跨平台构建"
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid ""
"Command-line tools like `kubectl` are often written in languages like C, Go or Rust and compiled to native executables for various target platforms.\n"
"This is great because you don't need to rely on Java installed; or being installed in a wrong version."
msgstr "`kubectl` 等命令行工具通常使用 C、Go 或 Rust 等语言编写,并编译成适用于各种目标平台的本地可执行文件。这很好,因为你不需要依赖 Java 的安装,也不需要安装错误的版本。"
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid ""
"With GraalVM native-images, this argument against Java does not hold anymore. Quarkus supports the build of native executables via GraalVM; mainly for building natively for Linux containers but there is experimental support for OS X and Windows as well.\n"
"Using the native build in combination with command-mode sounds like a very interesting and productive choice to write command-line tools."
msgstr "有了 GraalVM 原生图像,这种反对 Java 的论点就不再成立了。Quarkus 支持通过 GraalVM 构建本地可执行文件;主要用于构建 Linux 容器的本地可执行文件,但对 OS X 和 Windows 也有实验性支持。将本地构建与命令模式相结合,听起来是编写命令行工具的一个非常有趣且富有成效的选择。"
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid ""
"But how do you build your native executables for Linux, Mac and Windows?\n"
"If you are hosting your sources as a GitHub project, I can tell you that it is super-simple to get started. GitHub offers link:https://help.github.com/en/actions/building-and-testing-code-with-continuous-integration/setting-up-continuous-integration-using-github-actions[ Actions] which is a free service like link:https://travis-ci.org/[Travis CI] but fully integrated into the GitHub experience. Also, it offers runners (i.e. the build agents) for Linux, Mac and Windows."
msgstr "但如何为 Linux、Mac 和 Windows 构建本地可执行文件呢?如果你将源代码托管在 GitHub 项目中,我可以告诉你,这是个超级简单的入门方法。GitHub 提供的 link:https://help.github.com/en/actions/building-and-testing-code-with-continuous-integration/setting-up-continuous-integration-using-github-actions[Actions] 是一种类似 link:https://travis-ci.org/[Travis CI] 的免费服务,但已完全集成到 GitHub 体验中。此外,它还提供适用于 Linux、Mac 和 Windows 的运行程序(即构建代理)。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "To provide a native release-build for linux, place the following file under `.github/workflows` in your repo:"
msgstr "要为linux提供一个本地发布-build,请将以下文件放在你的 repo中的 `.github/workflows` 。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "This build-job is triggered when a new release is triggered. If your are the owner, you will have the button \"Draft a new release\" under link:https://github.com/38leinaD/quarkus-native-app-starter/releases[releases]"
msgstr "当一个新的版本被触发时,这个build-job就被触发了。如果你是所有者,你会在 link:https://github.com/38leinaD/quarkus-native-app-starter/releases[发布版下] 有一个 \"起草新的发布版 \"的按钮。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "Uses a ubuntu runner. See link:https://github.com/actions/virtual-environments[GitHub Actions Virtual Environments] for a list of all supported environments/runners."
msgstr "使用一个ubuntu运行器。所有支持的环境/运行器的列表见 link:https://github.com/actions/virtual-environments[GitHub Actions Virtual Environments] 。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "Set version in `pom.xml` based on specified release version"
msgstr "根据指定的发布版本,在 `pom.xml` 中设置版本"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "Build the native executable"
msgstr "构建本地可执行文件"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "Upload/attach the artifact to the release"
msgstr "上传/附加工件到版本中"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "Building for Mac just means to provide another job with `runs-on: macos-latest`."
msgstr "为Mac构建只是意味着提供另一份工作, `runs-on: macos-latest` 。"
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid ""
"Windows is essentially the same but requires a little more attention and knowledge about the tooling. Getting it working required some investigation on how the native build depends on Visual Studio. Also,the Windows runners on GitHub Actions have a too small page-file by default. That needs increasing as the memory consumption is rather high when running the GraalVMs `native-image` command.\n"
"An full example of a working native-image build under windows can be found link:https://github.com/38leinaD/quarkus-native-app-starter/blob/master/.github/workflows/release-build-native-win64.yml[here]."
msgstr "Windows 本质上是一样的,但需要更多的关注和工具知识。要让它正常工作,需要对本地构建如何依赖 Visual Studio 进行一些调查。此外,GitHub Actions 上的 Windows 运行程序默认的页面文件太小。由于运行 GraalVMs `native-image` 命令时内存消耗很大,因此需要增加页面文件。在 link:https://github.com/38leinaD/quarkus-native-app-starter/blob/master/.github/workflows/release-build-native-win64.yml[这里] 可以找到在 Windows 下构建原生镜像的完整示例。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "After triggering a release from the GitHub UI, the jobs for all target environments are triggered. The artifacts for all platforms are will be available within minutes and can be consumed by your users. Building, hosting: 100% free and no external service or registration needed."
msgstr "从GitHub用户界面触发发布后,所有目标环境的工作都会被触发。所有平台的工件将在几分钟内可用,并可以被你的用户所使用。构建、托管。100%免费,不需要外部服务或注册。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "image:github-actions.jpg[]"
msgstr "image:github-actions.jpg[alt=\"github actions\"]"
#. type: Title ==
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy, no-wrap
msgid "Command-mode for UI-based applications"
msgstr "基于用户界面的应用程序的命令模式"
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid ""
"Another exciting thing about command-mode is that it not only allows to write nice command-line tools (using e.g. link:https://picocli.info/[Picocli], link:http://aeshell.github.io/[Aesh] or link:https://commons.apache.org/proper/commons-cli/[Apache Commons CLI]) but in general allows to have more control over the lifecycle of an application.\n"
"With the possibility to embed your HTML/Javascript frontend, we can even build link:https://www.electronjs.org/[Electron-style] desktop application with rich user interfaces for our tools. As even JSF most likely will be link:https://github.com/adminfaces/quarkus-admin-starter[coming to Quarkus], there is a great variety of choices on how to build a frontend."
msgstr "命令模式的另一个令人兴奋之处在于,它不仅可以编写漂亮的命令行工具(例如使用 link:https://picocli.info/[Picocli] 、 link:http://aeshell.github.io/[Aesh] 或 link:https://commons.apache.org/proper/commons-cli/[Apache Commons CLI] ),还可以在总体上对应用程序的生命周期进行更多控制。有了嵌入 HTML/Javascript 前端的可能性,我们甚至可以为我们的工具构建具有丰富用户界面的 link:https://www.electronjs.org/[Electron 风格] 桌面应用程序。即使是 JSF 也很有可能加入 link:https://github.com/adminfaces/quarkus-admin-starter[Quarkus] ,因此在如何构建前端方面有多种选择。"
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid ""
"A very simple scaffold does not require much. If you have `quarkus-resteasy` as a dependency, the embedded server will be started on port `8080` just like in any regular Quarkus backend application.\n"
"As your tools might be running on a developer system alongside other app-servers or Quarkus instances, it is a good idea to choose a different port to not run into conflicts."
msgstr "一个非常简单的脚手架并不需要太多东西。如果将 `quarkus-resteasy` 作为依赖项,嵌入式服务器将在 `8080` 端口启动,就像在任何普通的 Quarkus 后端应用程序中一样。由于你的工具可能与其他应用服务器或 Quarkus 实例一起运行在开发者系统上,因此最好选择不同的端口,以免发生冲突。"
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid ""
"Configuring `quarkus.http.port=0` in your `application.properties` will make Quarkus choose a random but free port.\n"
"How to know from within your application which port it is? When injecting the config-property via `@ConfigProperty(name = \"quarkus.http.port\")`, you will get the assigned port."
msgstr "在 `application.properties` 中配置 `quarkus.http.port=0` 将使 Quarkus 随机选择一个空闲端口。如何在应用程序中知道是哪个端口?当通过 `@ConfigProperty(name = \"quarkus.http.port\")` 注入配置属性时,您将获得分配的端口。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "Assuming you have your front-end under `src/main/resources/META-INF/resources` (in my example it is plain HTML with Javascript) and using a very old Java API (`Desktop.getDesktop().browse(...)`), you can spin up the default browser to your app like this:"
msgstr "假设你的前端在 `src/main/resources/META-INF/resources` (在我的例子中,它是带有Javascript的纯HTML),并使用非常老的Java API( `Desktop.getDesktop().browse(…)` ),你可以像这样为你的应用程序启动默认浏览器。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "Get the assigned port"
msgstr "获得分配的端口"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "Open the `index.html` of your webapp with the default browser."
msgstr "用默认浏览器打开你的网络应用程序的 `index.html` 。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "Do not exit immediately but wait until the browser/tab is closed. See below for options how to do this."
msgstr "不要立即退出,而是等到浏览器/标签关闭后再退出。如何做到这一点,请看下面的选项。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "There are some more considerations here to make it work reliably."
msgstr "这里还有一些考虑,以使其可靠地工作。"
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid ""
"Ending the application when the browser window closes requires some feedback. There are simple ways to achieve this in a semi-reliabe way (see the usage of link:https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event[unload] in link:https://github.com/38leinaD/quarkus-native-app-starter/blob/master/src/main/resources/META-INF/resources/index.html#L89[index.html] by calling link:https://github.com/38leinaD/quarkus-native-app-starter/blob/master/src/main/java/org/acme/LsResource.java#L38[a rest endpoint]).\n"
"For Desktop-class applications, one might have to control the browser process more closely; or, like Electron, even package an own version of Chrome."
msgstr "在浏览器窗口关闭时结束应用程序需要一些反馈。有一些简单的方法可以半可靠地实现这一点(参见通过调用 link:https://github.com/38leinaD/quarkus-native-app-starter/blob/master/src/main/java/org/acme/LsResource.java#L38[休息端点] 在 link:https://github.com/38leinaD/quarkus-native-app-starter/blob/master/src/main/resources/META-INF/resources/index.html#L89[index.html] 中 link:https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event[卸载] 的用法)。对于桌面级应用程序,可能需要更紧密地控制浏览器进程;或者像 Electron 一样,甚至打包一个自己的 Chrome 浏览器版本。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "A problem I was facing is that `Desktop.getDesktop().browse(...)` does not seem to work reliably when run in native mode with the GraalVM version I was using (link:https://github.com/oracle/graal/issues/2430[issue]). The alternative, like already stated before, is to control the browser more directly and for example open a Chrome window via link:https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#exec(java.lang.String)[Runtime.exec(...)]. See the link:https://github.com/38leinaD/quarkus-native-app-starter/blob/master/src/main/java/org/acme/LsMain.java[main method] of the starter project for some possibilities to experiment with."
msgstr "我面临的一个问题是, `Desktop.getDesktop().browse(…)` ,在我使用的GraalVM版本 link:https://github.com/oracle/graal/issues/2430[(问题] )中以本地模式运行时,似乎不能可靠地工作。如前所述,另一种方法是更直接地控制浏览器,例如通过 link:https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#exec(java.lang.String)[Runtime.exec(...)] 打开一个Chrome窗口。请看启动项目的 link:https://github.com/38leinaD/quarkus-native-app-starter/blob/master/src/main/java/org/acme/LsMain.java[主要方法] ,以了解一些实验的可能性。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "image:quarkus-native-webui.gif[]"
msgstr "image:quarkus-native-webui.gif[alt=\"quarkus native webui\"]"
#. type: Title ==
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy, no-wrap
msgid "Summary"
msgstr "摘要"
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid ""
"It will be interesting to see where people are taking command-mode. Maybe we will be seeing Electron-style Desktop applications being developed based on Quarkus?\n"
"At least to me, this sounds promising and productive. No wasting of time to learn a completely different stack just to write a small tool. Instead, use the same stack and API I am familar with from backend development anyway."
msgstr "让我们拭目以待,看看人们将如何使用命令模式。也许我们会看到基于 Quarkus 开发的 Electron 风格桌面应用程序?至少在我看来,这听起来很有前途,也很有成效。不必为了编写一个小工具而浪费时间去学习完全不同的堆栈。取而代之的是,使用我在后端开发中熟悉的堆栈和 API。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "We have seen that making a tool available in a way that is easy to consume by people can be achived with GitHub and GitHub Actions alone."
msgstr "我们已经看到,仅靠 GitHub 和 GitHub Actions 就能以方便人们使用的方式提供工具。"
#. type: Plain text
#: _posts/2020-05-12-native-command-mode-tools.adoc
#, fuzzy
msgid "In case you are interested in a more complete tool where I have used the ideas presented here, check out my link:https://github.com/38leinaD/bpmn-diff[bpmn-diff] project which is a Git difftool for BPMN files. As an added benefit, it uses Gradle as opposed to Maven and thus provides additional examples on the use of GitHub Actions."
msgstr "如果您对我在这里介绍的更完整的工具感兴趣,可以查看我的 link:https://github.com/38leinaD/bpmn-diff[bpmn-diff] 项目,这是一个用于 BPMN 文件的 Git difftool。另外,它使用的是 Gradle 而不是 Maven,因此提供了更多使用 GitHub Actions 的示例。"