Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: don't use fallback key as button text #55

Merged
merged 3 commits into from
May 6, 2024
Merged

Conversation

awesomerobot
Copy link
Member

@awesomerobot awesomerobot commented May 6, 2024

When a non-US locale is the site's default, and the user chooses a US locale, the button would render the fallback key when no translation is set:

Before:
image

After:
image

So I've added a check for the default key, which should be considered false.

Originally reported here: https://meta.discourse.org/t/bug-with-search-banner-search-button-text-shown-in-search-banner-theme-component/273628

I think this is because the translation is being used in an unexpected way as a pseudo-setting (i.e., if it's empty, don't render the button)

@CvX
Copy link
Contributor

CvX commented May 6, 2024

btw, better yet - there's a translatedFallback option to i18n.t() where you can specify the fallback, and in this case I think you could use false as the value

@awesomerobot
Copy link
Member Author

hmm unfortunately that doesn't seem to work in this case, I can get translatedFallback to work if I use a string, but using false or an empty string returns the translation key again

@awesomerobot awesomerobot merged commit 9173272 into main May 6, 2024
4 checks passed
@awesomerobot awesomerobot deleted the locale-fix branch May 6, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants