oqtane/oqtane.translations

SharedResources

Closed this issue · 13 comments

As we are under way with translations, I thing we should address shared resources. Why would we translate 50+ times "Add" or "Delete", "Update" we can have one single resource key that is stored in the SharedResources.resx file.

I have created an example for module developent which can be easily applied to the framework.

https://github.com/leigh-pointer/StudioElf.LocSharedRes

Thoughts ?

Yes I agree. There was a SharedResources class which @hishamco already created here:

oqtane.framework\Oqtane.Client\Localization\SharedResources.cs

However it does contain some keys defined - whereas your class is empty?

@sbwalker the class is ment to be empty. The SharedResources.cs is the pointer to the Resx file SharedResources.resx which you will find at the route of the Resources folder. As we inject

@inject IStringLocalizer<Edit> Localizer

We inject as well
@inject IStringLocalizer<SharedResources> SharedResources

There is no need for the constants in the SharedResources.cs they should be in the ResX

@hishamco introduced the SharedResources class because he needed a solution for localizing the Admin page names. And instead of using magic strings he thought it would be better to define the keys in code. However, I do not really see the benefit since every other aspect of localization relies on magic strings as keys for doing lookups.

However, I do not really see the benefit since every other aspect of localization relies on magic strings as keys for doing lookups.

I agree, I think it would be better as a resx then it will be translatable.

Once the resource structure is applied in the repo I'm happy to get this impletmented.

I actually have someone going through the entire UI this week to ensure all resource strings are captured in *.resx files - and I will have them tackle the shared resources at the same time.

I actually have someone going through the entire UI this week to ensure all resource strings are captured in *.resx files - and I will have them tackle the shared resources at the same time.

Ok, but here to help.

@leigh-pointer does the sharedresources.cs class need to be placed in the project root?

@leigh-pointer does the sharedresources.cs class need to be placed in the project root?

@sbwalker as a rule yes and should have the namespace Oqtane.Client

@leigh-pointer could you please tell what's the wrong with the static resources implementation that I started?

could you please tell what's the wrong with the static resources implementation that I started?

@hishamco It wasn't following the .net pattern

Here is the .netcore link on Localisation and SharedResources. https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-5.0

I use this approach in my module dev and I know that it works and is standardized

Can I know how is differ from the one we added?

No further action