Changing SignIn submit button label
Hi,
I am trying to offer a auth experience in French by setting the right overrides (let me know if you think the approach is wrong BTW).
Turns out the label submit button for the SignIn form does not appears in overrides. Am I looking at the wrong component? Is there another way to change the label? Should it be added to overrides?
Cheers
16 Replies
You’re right. Looking at the code it tries to generate the button label based on the name of the action. https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password/input.ex
GitHub
ash_authentication_phoenix/input.ex at main · team-alembic/ash_auth...
Drop-in authentication support for Phoenix apps using AshAuthentication. - ash_authentication_phoenix/input.ex at main · team-alembic/ash_authentication_phoenix
Is there a conventional way to do translations with Phoenix? I did a quick search of the docs but didn’t find anything useful. Sorry, my English speaking privilege is showing.
gettext is the way. If you generate a new phoenix app you’ll see it
Right. Let’s add a card to add translation support.
I think at the moment the short term thing to do is also offer just the submit button text as an override if it isn’t already right?
It’s hard because it’s the same component used for all the form submit buttons so it’s derived from the action name.
Oh interesting…
Do overrides have to be strings?
Thanks for your help guys. I had discarded
gettext
as not well supported (yet) and overkill for a single-language website. I might end up using it, though, as well as ex_cldr
for dates, currencies...
What do you think of a verbose_name
or display_name
in the action and attribute DSLs to control the display? When specified, it could be used the humanize(action.name)
in this instance, or for example to_name(attribute.name)
in AshAdmin.If we can override with a function or an mfa that could also do it
Wouldn't the override have to be reimplemented for each extension (
AshAdmin
and AshAuthentication
for example) while specifying the name at resource level could be done only once for all usages?It would, but im not sure that the button is exactly the action name turned into something readable right?
And like you might want a button that says “Just let me I n!”
But you wouldn’t want to be setting a global name to that
I see 3 possible mechanisms for customization:
1. Action atom name turned into something readable is what we have now in several extensions and I think it's cool for rapid development.
2. Resource level display name for actions and attributes would allow to adjust the UI in the whole app with a single code change, no need to change every atom in the codebase. You can provide more info and detailed names to the app users without coupling the code to the UX considerations.
3. Overrides for customizing precise parts of the UI when you want to get fancy, with as many code change as UI changes, they make a lot of sense to for classes or funny messages.
Ash provides 1, and 3 for a given set of changes. I am convinced 2 would be useful too, even with more customization options in 3. I made heavy use of the feature in Django, for what it's worth.
Thanks for your time Zach, curious to hear your thoughts on this.
I don't have any problems with using a display name for an action, I just don't think it would help with this immediate thing. I think that you're right and that it could help in plenty of ways.
But here is what we currently do to get the button text
For people with multiple sign in strategies, the two actions would need different display names, so they might have one like
"Sign In With Password"
and "Sign In With Magic Link"
or something
but if we're using the display name for the button text, you don't want your UI showing "Sign In With Password"
You probably just want it to say Sign In
I see, thank you for clarifying.
You're right: If we put the code you posted in a function
name_from_atom
and the text is
it's awkward because the default "humanized atom" is smarter than the provided display name...
I would give the "Sign In With Pasword" a shorter (ironic, I know) display name "Se connecter" and it would solve my problem, but it definitely feels hackish and a loss of relevant info.I think in this instance, a functional override would be ideal, just don't know if the current system can support non-string overrides
@axelb can you make an issue for this in ash_authentication?
if you haven't already? Then we'll close this thread.
Ok, I will create one ticket for "Functional override" and one ticket "Support localization" if that's ok with you.
Done