Customizing text in auth plugin outside of after_initialize

AI-generated summary

The discussion revolves around customizing text in an auth plugin outside of after_initialize. RGJ is trying to make the authenticate button text for an external authentication provider configurable, but is facing issues with I18n and SiteSetting not being available at that stage. RGJ found that GlobalSetting can be used, but prefers SiteSetting or I18n for easier customization.

david suggests omitting the title parameter, allowing Discourse to use a translation string at runtime, which can be customized via the ‘customize text’ UI. This approach is used in modern auth plugins, and david provides examples from the discourse-apple-auth plugin.

RJG confirms that this solution works, and thanks david for the help.

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')

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

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)

That worked like a charm!! Thank you!