You simply need to add a
config/locales/server.zh_CN.yml
file (and similar for any other locales you want to support) with the same English tokens but with language specific values and the plugin will use that instead of falling back to the English.
「いいね!」 2
1c7
(Cheng Zheng)
2018 年 4 月 29 日午前 5:52
22
Thanks for helping! have a nice day!
「いいね!」 3
I was looking how to create a site setting that validates a username, but found there’s a username type to do this. Here the list of site setting types we have today:
email
username
integer
regex
string
list
enum
Also, you can do custom validations for your plugin settings, it accepts a validator field that expects a Ruby class. You use it like this.
plugins:
my_custom_username_validation:
default: 'system'
validator: 'UsernameSettingValidator'
You can check the UsernameSettingValidator class to see the interface of validators.
Cheers!
「いいね!」 10
Dev_Work
(Aleksandr)
2019 年 12 月 18 日午前 7:52
24
not working (
<a id="forgot-password-link" class="forgot-password" href="{{Discourse.SiteSettings.myplugin_link_forgot_password}}" target="_blank">Forgot password?</a>
settings.yml
plugins:
myplugin_enabled:
default: true
client: true
myplugin_link_forgot_password:
default: ''
client: true
upd:
working!!!
href="{{unbound siteSettings.myplugin_link_forgot_password}}"
Dev_Work
(Aleksandr)
2019 年 12 月 28 日午後 12:20
25
how to display text html ?
not working {{unbound siteSettings.forum_text_for_admin}}
upd:
working in *.hbs {{{unbound siteSettings.forum_text_for_admin}}}
merefield
(Robert)
2019 年 12 月 28 日午後 12:29
26
Again you need to use a Computed Property and format as safe html. This is EmberJS not vanilla JavaScript. You can’t put ‘code’ directly into templates. Read the ember guides.
「いいね!」 1
Dev_Work
(Aleksandr)
2019 年 12 月 28 日午後 12:36
27
already working with EmberJS
bitmage
(Brandon Mason)
2025 年 2 月 28 日午後 4:22
33
settings.yml に以下のような設定があります。
plugins:
county_fence_enabled:
default: false
client: true
county_fence_latrine_category:
default: -1
client: true
/admin/plugins ページには以下のように表示されます。
なぜ「設定」ボタンが表示されないのか分かりません。
私は、plugins の代わりに county_fence というプラグイン名を書くべきだと思います。
「いいね!」 2
bitmage
(Brandon Mason)
2025 年 3 月 4 日午前 12:40
35
それも試しましたが、違いはありませんでした。
このドキュメント (OPと同様)では plugins キーが使用されています。他の場所では、あなたが言ったようにプラグイン名が使用されているのを見ました。
「いいね!」 1
@bitmage 実は、その理由を知っているかもしれません。
plugin.rbに# name: County Fenceと書きましたか?
もしそうなら、名前はあなたのディレクトリ名と同じでなければいけません。
プラグイン名はローカル設定から上書きできます:
次の設定フォーマットがあると仮定します:
county_fence:
county_fence_enabled: true
...
client.en.ymlでは:
en:
admin_js:
admin:
site_settings:
categories:
county_fence: "County Fence"
bitmage
(Brandon Mason)
2025 年 3 月 4 日午前 3:21
37
デフォルト値を-1ではなく0に設定したところ、表示されるようになりました。
型の検出が正しく行われていないことを知る方法はありますか?
YamlLoader がファイルをロードします。
SiteSettingExtension が setting() を呼び出します 。パラメータは YamlLoader によって生成されます。
…これは defaults.load_setting を呼び出し、その後 type_supervisor.load_setting を呼び出します。
type_supervisor.load_setting には値が直接渡されませんが、TypeSupervisor が DefaultsProvider 経由で初期化される際にデフォルト値が渡されているため、アクセスできます。
type_supervisor.load_setting は get_data_type を呼び出し、これは parse_value_type() を呼び出します。型が検出できない場合は ArgumentError を発生させるはずです。
この一連の処理は、SiteSetting モデルの load_settings によって呼び出されていると思われますが、スタックのどこにも例外処理が見当たりません。しかし、サーバーログやその他の場所でエラー出力が見られません。
設定の解析に失敗したことを示す、何らかのユーザーフィードバックやエラーログがあるはずだと思います。
もし私の理解が正しければ、設定でデフォルト値として-1を使用すると、「設定」ボタンが表示されなくなるということですね。毎回この動作を再現できますか?
それは奇妙ですね。設定に問題は見当たりませんが、解析に失敗する可能性がどうしてあるのか分かりません。
bitmage
(Brandon Mason)
2025 年 3 月 4 日午前 4:40
39
これで動作するので、-1 に戻しても機能し続けます。
データベースを削除し、再初期化しましたが、再現できません。
「いいね!」 1
bitmage
(Brandon Mason)
2025 年 3 月 6 日午後 4:40
40
プラグインを安全のためデフォルトの0のまま本番サイトにデプロイしました。設定ボタンは表示されます。
しかし、クリックしても設定が表示されません。
この問題のトラブルシューティングを続ける間、プラグインを無効にします。
bitmage
(Brandon Mason)
2025 年 3 月 6 日午後 8:26
42
Ok、開発と本番の両方で、plugins ディレクトリ内のフォルダが county-fence と一致しなかったことが原因だったと思います。それが設定が表示されなかった理由であり、他の問題を引き起こした可能性もあります。
皆さん、ありがとうございました!
「いいね!」 1
私には不明瞭です。インストールしたプラグインのほとんどは、公式および最近のプラグイン(スケルトンテンプレート を含む)でも、plugins:を使用していません。
その部分は設定のフィルタリングに使用されると思っていましたが、間違っているかもしれません。
「いいね!」 1
なるほど、興味深いですね!では失礼しました。
必要ないとのことですが。
plugins: を使って私が作成したプラグインの数は数えきれません。
「いいね!」 1
bitmage
(Brandon Mason)
2025 年 3 月 15 日午後 6:42
45
ドキュメントを拡張するために:
Site Settings のタイプの完全なリストは、type_supervisor.rb コード で利用可能です。そのすぐ上には、Site Setting が受け入れる有効な子キーも表示されています。
これらのオプションの多くを使用した、より高度な例は、discourse-welcome-link テーマコンポーネント で見つけることができます。これらの値はプラグイン内でも機能するはずですが、ファイルは config/settings.yml になります。
「いいね!」 3
プラグインとテーマコンポーネントのタイプには違いがあります。
表を作成してみました(軽微なエラーやグループ化は想定内です)。
カテゴリ
機能
プラグイン構文
TC構文
基本タイプ
文字列
type: stringmin: ..max: ..regex: ..secret: true/false globalvalidator: クラス名
type: stringmin: ..max: .. - - - -
複数行テキスト
type: stringtextarea: true
type: stringtextarea: true
整数
type: integermin: ..max: ..
type: integermin: ..max: ..
浮動小数点数
type: floatmin: ..max: ..
type: floatmin: ..max: ..
ブール値
type: bool
type: bool
時間
type: time
-
Null
type: null
-
選択タイプ
Enum(ドロップダウン)
type: enumchoices: [option1, option2]enum: ..
type: enumchoices: [option1, option2]
カテゴリ
type: category
-
色
type: color
-
グループ
type: group
-
メールアドレス
type: email
-
ユーザー名
type: username
-
リストタイプ
一般的なリスト
type: listallow_any: true/false
type: list
シンプル/コンパクトリスト
type: simple_list またはtype: listlist_type: compactlist_type: simple
type: listlist_type: compactlist_type: simple
カテゴリリスト
type: category_list
type: listlist_type: category
グループリスト
type: group_list
type: listlist_type: group
タグリスト
type: tag_list
type: listlist_type: tag
タググループリスト
type: tag_group_list
-
URLリスト
type: url_list
-
ホストリスト
type: host_list
-
値リスト
type: value_list
-
絵文字リスト
type: emoji_list
-
ファイルタイプ
アップロード
type: upload
type: upload
アップロードされた画像リスト
type: uploaded_image_list
-
ファイルサイズ制限
type: file_size_restrictionmin: ..max: ..
-
特殊タイプ
HTML(非推奨)
type: html_deprecated
-
JSONオブジェクト
非推奨
非推奨
オブジェクト
-
type: objects
「いいね!」 5