Customizing text in auth plugin outside of after_initialize

I’m trying to make the authenticate button text for an external authentication provider configurable.

However, since the auth_provider call must be outside of after_initialize (because it must be loaded before OmniAuth is initialized) I am running into some impediments

I18n is not working.
SiteSetting is not there yet.

I found out that GlobalSetting is usable at this stage, but I would prefer to use one of the above methods, since those can be changed from within the Admin web interface and a GlobalSetting cannot.

Is there something I can do to be able to use SiteSetting or I18n here?

So I have

auth_provider title: 'with provider'

I can use
auth_provider title: GlobalSetting.try(:name_of_setting)

But I would like to use
auth_provider title: SiteSetting.name_of_setting
or
auth_provider title: I18n.t('button_text_slug')

3 Likes

Does anyone have any pointers about this? @sam ? @david ?

1 Like

If you omit the title parameter, then Discourse will reach for a translation string at runtime. Then people can customize it via the ‘customize text’ UI. That’s the approach we take on our modern auth plugins (although some still use the old method for backwards compatibility)

5 Likes

That worked like a charm!! Thank you!

2 Likes