Beginner's Guide to Creating Discourse Plugins Part 3: Custom Settings

plugins
(Mittineague) #21

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 Likes

(Cheng Zheng) #22

Thanks for helping! have a nice day!

3 Likes

(Orlando Del Aguila) #23

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!

8 Likes