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

RouterTabs: Adds localization #5948

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tesar-tech
Copy link
Collaborator

Description

Closes #5945

The feature is complete, but the documentation still needs to be updated. I’d like to discuss the approach first.

Implementation Overview

  1. Adding Options to AddBlazoriseRouterTabs
    The implementation introduces an option to AddBlazoriseRouterTabs that accepts a Func NamesLocalizer:

    builder.Services
        .AddBlazorise()
        .AddBlazoriseRouterTabs(
            opt => opt.NamesLocalizer = nameLocalizationKey =>
                applicationLocalizerDictionary[nameLocalizationKey]
        );

    This approach works similarly to how global localization is applied to validation messages.

  2. Using a Key Instead of a Name in the Attribute
    A key can now be provided inside the attribute, enabling localized naming:

    @attribute [RouterTabsPage(NameLocalizationKey: "myKeyForThisPage", Closeable: true)]

@tesar-tech tesar-tech requested a review from stsrki January 22, 2025 11:55
Copy link
Collaborator

@stsrki stsrki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The global API seems good to me. But I would also like to have a localizer API on RouterTabs. Look at DataGrid for example:

[Parameter] public DataGridLocalizers Localizers { get; set; }


Also, for undefined NameLocalizationKey I would pass Name as a key.

@tesar-tech
Copy link
Collaborator Author

The global API seems good to me. But I would also like to have a localizer API on RouterTabs. Look at DataGrid for example:

[Parameter] public DataGridLocalizers Localizers { get; set; }

From what I understood about the DataGridLocalizer, these are used for translating build-in parts of the DataGrid, like text on "new" button, "cancel" button, etc. There is nothing like that on RouterTabs, all the text is custom - there is no default value from Blazorise...

Also, for undefined NameLocalizationKey I would pass Name as a key.

What would be the use-case here?

The current solution is designed to support either the Name parameter or the NameLocalizationKey parameter, which are handled through two different constructors.

  • If the Name parameter is specified, the NameLocalizationKey will remain undefined, and Name will be used as is.
  • If users want localization, they need to specify the NameLocalizationKey and leave the Name parameter empty.

@stsrki
Copy link
Collaborator

stsrki commented Jan 23, 2025

The global API seems good to me. But I would also like to have a localizer API on RouterTabs. Look at DataGrid for example:
[Parameter] public DataGridLocalizers Localizers { get; set; }

From what I understood about the DataGridLocalizer, these are used for translating build-in parts of the DataGrid, like text on "new" button, "cancel" button, etc. There is nothing like that on RouterTabs, all the text is custom - there is no default value from Blazorise...

Also, for undefined NameLocalizationKey I would pass Name as a key.

What would be the use-case here?

The current solution is designed to support either the Name parameter or the NameLocalizationKey parameter, which are handled through two different constructors.

  • If the Name parameter is specified, the NameLocalizationKey will remain undefined, and Name will be used as is.
  • If users want localization, they need to specify the NameLocalizationKey and leave the Name parameter empty.

For other components, we use the Name as a key for localization. And if localization doesn't exist or is not found than that Name is displayed in the UI. We never used a specialized LocalizationKey in any other component. That's why I would like to go the same route for RouterTabs.

@tesar-tech tesar-tech marked this pull request as ready for review January 23, 2025 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add localization for RouterTabs
2 participants