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

Dashboard widget localization #17257

Open
Habbni opened this issue Dec 18, 2024 · 6 comments
Open

Dashboard widget localization #17257

Habbni opened this issue Dec 18, 2024 · 6 comments

Comments

@Habbni
Copy link
Contributor

Habbni commented Dec 18, 2024

Currently when you localize a dashboard widget, let´s say English and German, you end up with both versions being displayed in the dashboard:

grafik

I just ran into this in a project and I think it should only display the english OR the german version, depending on the currently selected language. This could easily be achieved with a small modification in the dashboard.wrapper, without breaking anything.

Is my point valid, should I put up a pull request?

@Piedone
Copy link
Member

Piedone commented Dec 18, 2024

Generally yes, there shouldn't be a duplicate. However, we only support localization of widgets with layers. How did you attempt this?

@Habbni
Copy link
Contributor Author

Habbni commented Dec 19, 2024

In my case users manage their dashboard with the AdminDashboard Module. That allows to place contents of stereotype "DashboardWidget", which is the hard coded behaviour. They can arrange simple text message on the dashboard.

I couldnt figure out a way to make this work with Layers. As far as I see, the behaviour there is to handle stereotype "Widget", so you cant even configure the widgets of the AdminDashboard there?

Users can localize the text widgets with an attached LocalizablePart. As there is no filter mechanic though, every translation gets rendered everytime..

The approach is to check if the widget is localized, and if so, compare it with the users culture to prevent rendering completely if necessary. Very simple change here commit 1fa6b23

Currently I provide that by overriding the template and I´m also fine to continue doing so. Even better if there is a built-in solution, but I thought it´s worth sharing

@Piedone
Copy link
Member

Piedone commented Dec 19, 2024

I see, thanks for explaining. I assumed you used Localization Part but wanted to check. I think we can add a filter for this to the module, but there are two things that makes it more complicated than the solution you linked:

  • The filtering should happen already when fetching widgets. Discarding widgets when displaying them is not the best solution.
  • This should work without new dependencies: The AdminDashboard module should work without the Localization module and vice versa.

@Habbni
Copy link
Contributor Author

Habbni commented Dec 19, 2024

Sounds reasonable, it´s just been my only option without modifications to the platform and at least i was able to point out the issue this way. I will stick with my solution for now then and take a deeper look later

@sebastienros
Copy link
Member

Let's say you have en and es, en being the default language. Some widget types are localizable, and some widgets are localized.

I assume you would want to see the en widgets (or without language) for the types that are not localizable, and the ones in the current culture for the ones that are localizable.

@sebastienros sebastienros added this to the 2.x milestone Dec 19, 2024
Copy link
Contributor

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants