Can't customize text on custom button in template override using UI

I’m overriding one of the handlebars templates, static.hbs, so that I can create a custom login page.

I’ve been able to add a custom button instead of the Sign Up button, which will allow people to visit a pricing page to buy a membership through Memberful.

The challenge I have is that I’m not able to customize the text for the pricing button and I’m not sure why.

image

I’ve added the button as such:

{{d-button href="https://example.com/pricing" class="btn-primary pricing-button" label="pricing_button"}}

Yet when I go to Admin > Customize > Text and search for “pricing_button” it doesn’t show up.

I’ve run the Find a translation key with verbose localization and it shows in the console as Translation #36: pricing_button, but again, when I search the Admin > Customize > Text page, I don’t find it.

Any ideas what might be happening?

UPDATE: Seems that I’ll have to create this as a theme component with a repo, not just using the UI/UX, and that I have to add the pricing-button to the locale.

You need to add pricing-button to the locale. See Adding localizable strings to themes and theme components

2 Likes

Ah, I forgot to add that I did the template override in a new theme component that I created in the Admin menu, not in a separate git repo.

I tried doing it as such, by adding the theme-prefix in the label:

…but it didn’t seem to work.

Is it possible to add locales/custom text in a theme/component created in the admin page without having to create a git repo?

I don’t think you can do it with the UX; that’s really designed only for trivial changes.

I think that you’d need to use the Discourse Theme CLI (console app to help you build themes).

2 Likes

Haha, darn. For something so simple, I wish it could be just done in the UX.

Ok, looks as if I’ll have to create a proper theme component, thank you for your help!

2 Likes

Adding a locale isn’t so simple, but if you want it to be simple, you can try using

                translatedLabel="Actual Text!"

Instead of the label that uses a locale.

3 Likes

Fair point, I agree locales are much more complex. When I said simple, I meant it in the context of using a template override and adding a {{d-button}}.

However, you have solved my problem with the:

{{d-button href="https://example.com/pricing" class="btn-primary pricing-button" translatedLabel='Pricing'}}

Thank you so much!!

2 Likes

You’re so welcome! I had a similar issue with, for reasons, not wanting to put the label in locale in just the last week. :clinking_glasses:

2 Likes

:clinking_glasses: to you, to Discourse, and to the weekend :smiley:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.