From 985f83d231e59a276fb8b6883f7c6e18eb855b82 Mon Sep 17 00:00:00 2001 From: Zhongwen Deng Date: Thu, 21 Apr 2022 22:18:38 +0800 Subject: [PATCH] feat: add emqx_plugins i18n --- apps/emqx/src/emqx_schema.erl | 4 +- .../i18n/emqx_plugins_schema.conf | 93 +++++++++++++++++++ apps/emqx_plugins/src/emqx_plugins_schema.erl | 38 ++------ 3 files changed, 103 insertions(+), 32 deletions(-) create mode 100644 apps/emqx_plugins/i18n/emqx_plugins_schema.conf diff --git a/apps/emqx/src/emqx_schema.erl b/apps/emqx/src/emqx_schema.erl index ec3a54b2a..5751f4cf4 100644 --- a/apps/emqx/src/emqx_schema.erl +++ b/apps/emqx/src/emqx_schema.erl @@ -128,7 +128,7 @@ roots(high) -> {"mqtt", sc( ref("mqtt"), - #{ desc => ?DESC(mqtt)} + #{desc => ?DESC(mqtt)} )}, {?EMQX_AUTHENTICATION_CONFIG_ROOT_NAME, authentication( @@ -1268,7 +1268,7 @@ fields("sys_topics") -> {"sys_event_messages", sc( ref("event_names"), - #{ desc => ?DESC(sys_event_messages) } + #{desc => ?DESC(sys_event_messages)} )} ]; fields("event_names") -> diff --git a/apps/emqx_plugins/i18n/emqx_plugins_schema.conf b/apps/emqx_plugins/i18n/emqx_plugins_schema.conf new file mode 100644 index 000000000..2b88bbc6d --- /dev/null +++ b/apps/emqx_plugins/i18n/emqx_plugins_schema.conf @@ -0,0 +1,93 @@ +emqx_plugins_schema { + plugins { + desc { + en: """ +Manage EMQX plugins.
+Plugins can be pre-built as a part of EMQX package, +or installed as a standalone package in a location specified by +install_dir config key
+The standalone-installed plugins are referred to as 'external' plugins. +""" + zh: """管理EMQX插件。
+插件可以是EMQX安装包中的一部分,也可以是一个独立的安装包。
+独立安装的插件称为“外部插件”。 + """ + } + label { + en: "Plugins" + zh: "插件" + } + } + state { + desc { + en: "A per-plugin config to describe the desired state of the plugin." + zh: "描述插件的状态" + } + label { + en: "State" + zh: "插件状态" + } + } + name_vsn { + desc { + en: """The {name}-{version} of the plugin.
+It should match the plugin application name-version as the for the plugin release package name
+For example: my_plugin-0.1.0. +""" + zh: """插件的名称{name}-{version}。
+它应该与插件的发布包名称一致,如my_plugin-0.1.0。""" + } + label { + en: "Name-Version" + zh: "名称-版本" + } + } + enable { + desc { + en: "Set to 'true' to enable this plugin" + zh: "设置为“true”以启用此插件" + } + label { + en: "Enable" + zh: "启用" + } + } + states { + desc { + en: """An array of plugins in the desired states.
+The plugins are started in the defined order""" + zh: """一组插件的状态。插件将按照定义的顺序启动""" + } + label { + en: "States" + zh: "插件启动顺序及状态" + } + } + install_dir { + desc { + en: """ +The installation directory for the external plugins. +The plugin beam files and configuration files should reside in +the subdirectory named as emqx_foo_bar-0.1.0. +
+NOTE: For security reasons, this directory should **NOT** be writable +by anyone except emqx (or any user which runs EMQX). +""" + zh: "插件安装包的目录, 不要自己创建, 只能由emqx用户创建与修改" + } + label { + en: "Install Directory" + zh: "安装目录" + } + } + check_interval { + desc { + en: """Check interval: check if the status of the plugins in the cluster is consistent,
+if the results of 3 consecutive checks are not consistent, then alarm. +""" + zh: """检查间隔:检查集群中插件的状态是否一致,
+如果连续3次检查结果不一致,则报警。 +""" + } + } +} diff --git a/apps/emqx_plugins/src/emqx_plugins_schema.erl b/apps/emqx_plugins/src/emqx_plugins_schema.erl index b7498d2ee..eed85558c 100644 --- a/apps/emqx_plugins/src/emqx_plugins_schema.erl +++ b/apps/emqx_plugins/src/emqx_plugins_schema.erl @@ -23,7 +23,7 @@ , namespace/0 ]). --include_lib("typerefl/include/types.hrl"). +-include_lib("hocon/include/hoconsc.hrl"). -include("emqx_plugins.hrl"). namespace() -> "plugin". @@ -32,33 +32,22 @@ roots() -> [?CONF_ROOT]. fields(?CONF_ROOT) -> #{fields => root_fields(), - desc => """ -Manage EMQX plugins. -
-Plugins can be pre-built as a part of EMQX package, -or installed as a standalone package in a location specified by -install_dir config key -
-The standalone-installed plugins are referred to as 'external' plugins. -""" + desc => ?DESC(?CONF_ROOT) }; fields(state) -> #{ fields => state_fields(), - desc => "A per-plugin config to describe the desired state of the plugin." + desc => ?DESC(state) }. state_fields() -> [ {name_vsn, hoconsc:mk(string(), - #{ desc => "The {name}-{version} of the plugin.
" - "It should match the plugin application name-version as the " - "for the plugin release package name
" - "For example: my_plugin-0.1.0." + #{ desc => ?DESC(name_vsn) , required => true })} , {enable, hoconsc:mk(boolean(), - #{ desc => "Set to 'true' to enable this plugin" + #{ desc => ?DESC(enable) , required => true })} ]. @@ -72,27 +61,16 @@ root_fields() -> states(type) -> hoconsc:array(hoconsc:ref(?MODULE, state)); states(required) -> false; states(default) -> []; -states(desc) -> "An array of plugins in the desired states.
" - "The plugins are started in the defined order"; +states(desc) -> ?DESC(states); states(_) -> undefined. install_dir(type) -> string(); install_dir(required) -> false; install_dir(default) -> "plugins"; %% runner's root dir install_dir(T) when T =/= desc -> undefined; -install_dir(desc) -> """ -The installation directory for the external plugins. -The plugin beam files and configuration files should reside in -the subdirectory named as emqx_foo_bar-0.1.0. -
-NOTE: For security reasons, this directory should **NOT** be writable -by anyone except emqx (or any user which runs EMQX). -""". +install_dir(desc) -> ?DESC(install_dir). check_interval(type) -> emqx_schema:duration(); check_interval(default) -> "5s"; check_interval(T) when T =/= desc -> undefined; -check_interval(desc) -> """ -Check interval: check if the status of the plugins in the cluster is consistent,
-if the results of 3 consecutive checks are not consistent, then alarm. -""". +check_interval(desc) -> ?DESC(check_interval).