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

[Idea] Language switcher #538

Open
dkuku opened this issue Dec 15, 2024 · 2 comments
Open

[Idea] Language switcher #538

dkuku opened this issue Dec 15, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@dkuku
Copy link
Contributor

dkuku commented Dec 15, 2024

Thanks for the great project. Wdyt about adding somewhere a global language switcher.
It can be added as a variant that will show up with every story when storybook is configured for it. Often the length of the text changes the appearance of a component and with this change it would be easy to spot regressions.
Gettext has helpers that set the current locale in process dictionary - this is all that's needed:

iex(2)> Gettext.known_locales(AiConnector.Gettext)
["en", "pl"]
iex(3)> Gettext.get_locale
"en"
iex(4)> Gettext.put_locale("pl")
nil
iex(5)> Gettext.get_locale()
"pl"
@dkuku dkuku changed the title Language switcher [Idea] Language switcher Dec 15, 2024
@cblavier
Copy link
Contributor

Hey Daniel,

What you are suggesting makes sense.
Until it is implemented you can hijack theming features to call Gettest.put_locale/1 when a different theme is picked.

Have a look at :function theme strategy
https://github.com/phenixdigital/phoenix_storybook/blob/main/guides/theming.md#using-a-registry

@cblavier cblavier added the enhancement New feature or request label Dec 16, 2024
@cblavier
Copy link
Contributor

cblavier commented Jan 8, 2025

Hey Daniel, did the trick work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants