Custom Handlebars Template for Plugin

Hi,
In my plugin I have added a new button to the toolbar using the API’s addButton method. Now I would like to show a custom text when the user hovers over the button, just like “Insert date/time” when hovering over the calendar icon. However, setting the label property does not seem to work, I guess due to lacking i18n information. How can I register and access localized labels?
Kind regards
Alexander

1 Like

You should probably use the title attribute (instead of label) and set its value to the localized i18n variable defined in config/locals/client.en.yml for your plugin.

Here is how the discourse-local-dates plugin does it:

https://github.com/discourse/discourse/blob/master/plugins/discourse-local-dates/assets/javascripts/initializers/discourse-local-dates.js.es6#L14

and

https://github.com/discourse/discourse/blob/master/plugins/discourse-local-dates/config/locales/client.en.yml#L10

6 Likes

Hi,
I just spend 40 minutes debugging until I found out that my yml file ended up in config instead of config/locales :man_facepalming: Thank you for your help!
Alex

4 Likes