"trait"'i İngilizce diline çevirin

"trait" ifadesinin Çince ile İngilizce arasındaki 50 çevirisinden 50 tanesi gösteriliyor

trait kelimesinin Çince ile İngilizce çevirisi

Çince
İngilizce

ZH 正如 class 能够使用 trait 一样,其它 trait 也能够使用 trait。在 trait 定义时通过使用一个或多个 trait,能够组合其它 trait 中的部分或全部成员。

EN Just as classes can make use of traits, so can other traits. By using one or more traits in a trait definition, it can be composed partially or entirely of the members defined in those other traits.

ZH 从基类继承的成员会被 trait 插入的成员所覆盖。优先顺序是来自当前类的成员覆盖了 trait 的方法,而 trait 则覆盖了被继承的方法。

EN An inherited member from a base class is overridden by a member inserted by a Trait. The precedence order is that members from the current class override Trait methods, which in turn override inherited methods.

ZH 在本例中 Talker 使用了 trait A 和 B。由于 A 和 B 有冲突的方法,其定义了使用 trait B 中的 smallTalk 以及 trait A 中的 bigTalk。

EN In this example, Talker uses the traits A and B. Since A and B have conflicting methods, it defines to use the variant of smallTalk from trait B, and the variant of bigTalk from trait A.

ZH 示例 #7 从 trait 来组成 trait

EN Example #7 Traits Composed from Traits

ZH 自 PHP 8.1.0 起,弃用直接在 trait 上调用静态方法或者访问静态属性。 静态方法和属性应该仅在使用了 trait 的 class 中访问。

EN As of PHP 8.1.0, calling a static method, or accessing a static property directly on a trait is deprecated. Static methods and properties should only be accessed on a class using the trait.

ZH 上面的 patch trait 假定目标组件实例具有 spec.template.spec.affinity 字段。 因此,我们需要使用 applyToWorkloads 来强制执行该 trait,仅适用于具有此字段的那些 workload 类型。

EN The patch trait above assumes the target component instance have spec.template.spec.affinity field. Hence, we need to use appliesToWorkloads to enforce the trait only applies to those workload types have this field.

ZH trait 可以附加到指定或全部的工作负载类型("*" 表示你的 trait 可以与任何工作负载类型一起使用)。

EN A trait can be attached to specified workload types or all (i.e. "*" means your trait can work with any workload type).

ZH PHP 实现了一种代码复用的方法,称为 trait

EN PHP implements a way to reuse code called Traits.

ZH 通过逗号分隔,在 use 声明列出多个 trait,可以都插入到一个类中。

EN Multiple Traits can be inserted into a class by listing them in the use statement, separated by commas.

ZH 示例 #4 多个 trait 的用法

EN Example #4 Multiple Traits Usage

ZH 如果两个 trait 都插入了一个同名的方法,如果没有明确解决冲突将会产生一个致命错误。

EN If two Traits insert a method with the same name, a fatal error is produced, if the conflict is not explicitly resolved.

ZH 为了解决多个 trait 在同一个类中的命名冲突,需要使用 insteadof 操作符来明确指定使用冲突方法中的哪一个。

EN To resolve naming conflicts between Traits used in the same class, the insteadof operator needs to be used to choose exactly one of the conflicting methods.

ZH 为了对使用的类施加强制要求,trait 支持抽象方法的使用。 支持 public 、protected 和 private 方法。PHP 8.0.0 之前, 仅支持 public 和 protected 抽象方法。

EN Traits support the use of abstract methods in order to impose requirements upon the exhibiting class. Public, protected, and private methods are supported. Prior to PHP 8.0.0, only public and protected abstract methods were supported.

ZH Trait 同样可以定义属性。

EN Traits can also define properties.

ZH Trait 定义了一个属性后,类就不能定义同样名称的属性,否则会产生 fatal error。 有种情况例外:属性是兼容的(同样的访问可见度、初始默认值)。

EN If a trait defines a property then a class can not define a property with the same name unless it is compatible (same visibility and initial value), otherwise a fatal error is issued.

ZH 使用接口(interface),可以指定某个类必须实现哪些方法,但不需要定义这些方法的具体内容。 由于接口(interface)和类(class)、trait 共享了命名空间,所以它们不能重名。

EN Object interfaces allow you to create code which specifies which methods a class must implement, without having to define how these methods are implemented. Interfaces share a namespace with classes and traits, so they may not use the same name.

ZH 在本章节中,我们会展示如何使用 sidecar trait 来收集日志。

EN The sidecar trait allows you to attach a sidecar container to the component.

ZH 当前示例中,application vela-app 依赖 KubeVela 内置的 component(webservice) 和 trait(ingress)。我们也可以通过参数 -d 或者 --definitions 指定本地 definition 文件。

EN In this example, the definitions(webservice and ingress) which vela-app depends on is the built-in components and traits of KubeVela. You can also use -d or --definitions to specify your local definition files.

ZH KubeVela 中的 Trait 特性可以从基于Helm的组件无缝添加.

EN Traits in KubeVela can be attached to Helm based component seamlessly.

ZH 在以下应用实例中,我们将基于 Helm 组件添加两个 Trait 特性 scaler 和 virtualgroup.

EN In this sample application below, we add two traits, scaler and virtualgroup to a Helm based component.

ZH 注意: 当我们使用基于 Helm 的 Trait 特性时, 请确认在你 Helm 图标中的目标负载严格按照 qualified-full-name convention in Helm 的命名方式. 以此表为例, 负载名为版本名和图表名.

EN Note: when use traits with Helm based component, please make sure the target workload in your Helm chart strictly follows the qualified-full-name convention in Helm. For example in this chart, the workload name is composed of release name and chart name.

ZH 这是因为 KubeVela 依赖命名去发现负载,否则将不能把 Trait 特性赋予负载

EN This is because KubeVela relies on the name to discovery the workload, otherwise it cannot apply traits to the workload

ZH 当应用已被部署且 workload 负载/ Trait 特性都被顺利建立时, 你可以更新应用, 变化会被负载实例所响应.

EN After the application is deployed and workloads/traits are created successfully, you can update the application, and corresponding changes will be applied to the workload instances.

ZH 在应用部署完后(同时 workloads/trait 成功地创建),你可以执行更新应用的操作,并且更新的内容会被应用到 workload 上。

EN After the application is deployed and workloads/traits are created successfully, you can update the application, and corresponding changes will be applied to the workload.

ZH 在本节中,我们将介绍如何定义 Trait

EN In this section we will introduce how to define a trait.

ZH 可以通过简单地参考现有的 Kubernetes API 资源来定义 KubeVela 中的 Trait

EN A trait in KubeVela can be defined by simply reference a existing Kubernetes API resource.

ZH 让我们将此 Trait 附加到 Application 中的 Component 实例:

EN Let's attach this trait to a component instance in Application:

ZH 以下是 ingress 的 Trait 示例。

EN Below is an example for ingress trait.

ZH 让我们将此 Trait 附加到Application中的 Component 实例中:

EN Let's attach this trait to a component instance in Application:

ZH 基于 CUE 的 Trait 定义还可以支持许多其他高级方案,例如修补和数据传递。 在接下来的文档中将对它们进行详细说明。

EN CUE based trait definitions can also enable many other advanced scenarios such as patching and data passing. They will be explained in detail in the following documentations.

ZH 请注意,即使 patch trait 本身是由 CUE 定义的,它也可以修补任何 component,无论其基于什么原理(即 CUE,Helm 和任何其他受支持的方式)。

EN Note that even patch trait itself is defined by CUE, it can patch any component regardless how its schematic is defined (i.e. CUE, Helm, and any other supported schematic approaches).

ZH 下面是 node-affinity trait 的例子:

EN Below is an example for node-affinity trait:

ZH 默认情况下,KubeVela 中 patch trait 使用 CUE merge 操作。它具有以下已知约束

EN By default, patch trait in KubeVela leverages the CUE merge operation. It has following known constraints though:

ZH 在 Workload 和 Trait 中健康检查字段都是 spec.status.healthPolicy。

EN The spec of health check is spec.status.healthPolicy, they are the same for both Workload Type and Trait.

ZH 例如,如果已将 component 实例的值设置为 replicas=5,则修改 replicas 字段的任何 patch trait 都将失败,也就是你不应在其 component 定义中公开 replicas 字段。

EN For example, if a component instance already been set with value replicas=5, then any patch trait to patch replicas field will fail, a.k.a you should not expose replicas field in its component definition schematic.

ZH Trait 并不包含 context.output 字段,其他字段都是相同。

EN Trait will not have the context.output, other fields are the same.

ZH 自定义状态配置项为 spec.status.customStatus,Workload 和 Trait 中都是该字段。

EN The spec of custom status is spec.status.customStatus, they are the same for both Workload Type and Trait.

ZH 策略 patch trait 的示例如下所示:

EN The example of strategy patch trait will like below:

ZH 如果 patch and outputs 都存在于一个 trait 定义中,则将首先处理 patch 操作,然后呈现 outputs 。

EN If patch and outputs both exist in one trait definition, the patch operation will be handled first and then render the outputs.

ZH 因此,将 Service 附加到给定 component 实例的上述 trait 将首先为 workload 打上相应的标签,然后基于 outputs 中的模板呈现服 Service 资源。

EN So the above trait which attaches a Service to given component instance will patch an corresponding label to the workload first and then render the Service resource based on template in outputs.

ZH 如下所示,该示例将展示如何在 trait 中渲染多个 Kubernetes Services:

EN Below is an example that will render multiple Kubernetes Services in one trait:

ZH Patch Trait 的更多使用案例​

EN More Use Cases of Patch Trait​

ZH 通常,patch trait 非常有用,可以将操作问题与 component 定义分开,下面有更多示例。

EN Patch trait is in general pretty useful to separate operational concerns from the component definition, here are some more examples.

ZH 上面 trait 对象可以在以下 Application 被使用:

EN The usage of this trait could be:

ZH Trait Definition 中可以发送 HTTP 请求并借助字段 processing 将响应结果用于渲染资源。

EN The trait definition can send a HTTP request and capture the response to help you rendering the resource with keyword processing.

ZH 以上示例,该 Trait Definition 将发送请求获取 token 信息,并将数据插入到给定到 component 实例中。

EN In above example, this trait definition will send request to get the token data, and then patch the data to given component instance.

ZH processing.http 部分是高级功能,允许 trait 定义在渲染资源期间发送 HTTP 请求。有关更多详细信息,请参考特质定义中的执行HTTP请求 部分。

EN The processing.http section is an advanced feature that allow trait definition to send a HTTP request during rendering the resource. Please refer to Execute HTTP Request in Trait Definition section for more details.

ZH 在下面的教程中,你将学习将 KEDA 作为新的自动伸缩 trait 添加到基于 KubeVela 的平台中。

EN In the following tutorial, you will learn to add KEDA as a new autoscaling trait to your KubeVela based platform.

ZH 步骤 2: 创建 Trait Definition​

EN Step 2: Create Trait Definition​

ZH 要在 KubeVela 中将 KEDA 注册为一项新功能(即 trait),唯一需要做的就是为其创建一个 TraitDefinition 对象。

EN To register KEDA as a new capability (i.e. trait) in KubeVela, the only thing needed is to create an TraitDefinition object for it.

50 çeviriden 50 tanesi gösteriliyor