-
Notifications
You must be signed in to change notification settings - Fork 579
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
Support localization for Label component #771
Comments
IMHO the localization support can go with two way:
I will start a WIP PR and share my thought with you guys |
The initial proposal for the components could be something like:
So, there should be localized keys such as @sbwalker your thoughts |
My preference is that a developer should not have to specify the ResourceType property explicitly as it is extra work and seems redundant. The framework knows the component being rendered so it should be possible to internalize the implementation. Perhaps by adding an additional property for ComponentType to the Module model which is what the ModuleState CascadingParameter is based on. Set ComponentType in the router so that it is available to all downstream components. |
That's what I pointed to earlier in the discussion, agree with you
+1 |
@sbwalker I'm able to access module type not the page type, so can we set |
Can you explain how the type is used? My assumption is that it is the type of the module component being localized? So if a module ( ie. MyModule ) had an index.razor component and it had a bunch of Labels on it, then the type which would be needed for localization is MyModule.Index. Correct? I can’t really answer your question unless I understand the requirements. |
Right |
ModuleState is a cascading parameter which is already available in the Label component ( through ModuleBase ) and it has a property for ModuleType which provides the type of the related module component. |
The type of the module or the parent component that owns the label? |
The type of the parent component that owns the label |
what is ModuleStatus - there is no property named ModuleStatus. And I am not sure how it relates to localization? |
Sorry |
To capture the module type as you mentioned above |
Set a breakpoint in OnParamaterSet() in Oqtane.Client\Modules\Controls\Label.razor The reason why ModuleState was null for you is because you tried to use the Label component outside of module - which is not a valid use case. The whole idea in Oqtane is that your build modules, and all of the generic components such as Label, etc.. assume that they are being used within an Oqtane module which allows them to access the cascading parameters of PageState and ModuleState which provides access to all contextual properties. |
Thanks @sbwalker I will try what you said, but the localization should work with pages too without need hosting a label into a module, Am I right? |
I am not sure if I am understanding your question correctly, so please forgive me if I repeat some of the most basic concepts of Oqtane. Oqtane is a "modular framework" so its entire development model is based on modules - not pages. A developer should NEVER create a razor component with an @page directive ( ie, a standard razor page component ). "Pages" are a virtual concept in Oqtane - they are essentially metadata stored in a database which defines a route and which modules should be dynamically rendered when a user navigates to that route. So to answer your question, the Oqtane Label component should NEVER be used anywhere except for within a module. |
If your intend in Oqtane is to use the components inside a module, it's fine, I'm working on the PR now, hope to share a draft soon I'm struggling with reflection little bit coz you know |
@hishamco I am a bit concerned based on your comments in this thread. Have you created a module for Oqtane? The reason I said the Label component should NEVER be used anywhere except for within a module is because there is no other supported place in Oqtane for using a component. Type.GetType(ModuleState.ModuleType) will provide you with a type. |
Nope, but I used the
Frankly I tested the Label component when I filed the issue on
I already know that, but I will let you know in my PR why this will may not fit |
I think the issue because the generic param should be a Type not an object of type |
I have no code to look at so I cannot really understand or comment. |
No worry I will handle it and share the PR with you Thanks a lot |
@sbwalker can we add localization support to other components or shall we do it after |
It would definitely be useful to implement the ResourceKey concept on other Controls as it makes it much easier for developers to localize their modules. |
Ok, I will start some PRs tomorrow to make this happen |
As @sbwalker mentioned earlier
Now we should think about the challenges and use cases to make this happen, hopefully I will share my thought soon ...
The text was updated successfully, but these errors were encountered: