Skip to content

Conversation

@hishamco
Copy link
Member

Fixes part of #18455

/cc @MikeKry

@hishamco hishamco requested a review from sebastienros October 12, 2025 15:25
Copy link
Member

@gvkries gvkries left a comment

Choose a reason for hiding this comment

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

I feel this approach might be a bit overengineered. I’d suggest simply moving the functionality into the actual interface implementation and removing the static method from the interface. This would eliminate the need for the new CultureInfoWrapper class, which introduces additional complexity, especially with its use of async local ShellScope, which raises performance concerns.
Additionally, I’m not convinced that introducing an ICultureAliasProvider is necessary at this stage. It seems like an abstraction that doesn’t yet provide enough value to justify its inclusion.

@hishamco
Copy link
Member Author

I feel this approach might be a bit overengineered. I’d suggest simply moving the functionality into the actual interface implementation and removing the static method from the interface. This would eliminate the need for the new CultureInfoWrapper class, which introduces additional complexity, especially with its use of async local ShellScope, which raises performance concerns.

I might agree, but don't forget that we have two implementations for ILocalizationService if I recall, @sebastienros , correct me if I'm wrong, so rewriting the same implementation is not suited IMHO

Additionally, I’m not convinced that introducing an ICultureAliasProvider is necessary at this stage. It seems like an abstraction that doesn’t yet provide enough value to justify its inclusion.

If you look at the current localization APIs, there's already a rules provider, which might not be necessary, but it's good for flexibility and extensibility

@Skrypt, I forgot to ping you while you were doing many things in localization

@MikeKry
Copy link
Contributor

MikeKry commented Oct 14, 2025

@hishamco

as for me - this satisfies my need to add custom localization. Code looks good, and definitely cleaner than before :)

@gvkries
Copy link
Member

gvkries commented Oct 14, 2025

I might agree, but don't forget that we have two implementations for ILocalizationService if I recall, @sebastienros , correct me if I'm wrong, so rewriting the same implementation is not suited IMHO

I don’t think this is a major issue for such a small feature, but if needed, it could be implemented once as a static helper.
However, relying on the current ShellScope for this kind of logic doesn’t seem like a good design choice.

@hishamco
Copy link
Member Author

it could be implemented once as a static helper.
However, relying on the current ShellScope for this kind of logic doesn’t seem like a good design choice.

I agree, but as you know, there's no service locator pattern in OC AFAIK, that's why I'm using ShellScope

@sebastienros
Copy link
Member

I agree with @gvkries that the only change to do should be to convert this static method to one in the interface that can be implemented and customized wholly. The change should be very simple, and whatever was invoking the static method can now resolve the service directly. No need for a CultureWrapper either.

@sebastienros
Copy link
Member

To be clear, no need for ICultureAliasProvider either, the GetAllCultureAndAliases will return the union. If people want to change the aliases, they change GetAllCultureAndAliases.

@hishamco
Copy link
Member Author

I never mind, but don't forget that we have two implementations, so no need to duplicate the code twice; moreover, customizing the aliases might be a headache. FYI, we already have similar approaches in SystemRoleProvider and a few others, but I'm open to any suggestion that could be flexible and extensible

@gvkries
Copy link
Member

gvkries commented Oct 17, 2025

We do not expect that this has to be customized regularly and therefore it does not need to be another abstraction inside OC.
The DefaultLocalizationService may not require the implementation at all and could potentially just return either the .NET cultures, or just the same as the supported cultures.

@hishamco
Copy link
Member Author

We do not expect that this has to be customized regularly and therefore it does not need to be another abstraction inside OC.

I didn't expect further customization in IPluralRuleProvider too

https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore/OrchardCore.Localization.Core/DefaultPluralRuleProvider.cs

while OC is extensible from the ground up, let us do it the way that it should

@sebastienros
Copy link
Member

@hishamco it is abstracted. You can replace the whole implementation of the method. You even prove it by saying it will be duplicated in two implementations. We just don't need to split this method in two more concepts.

Someone who doesn't want to see these aliases can replace the method. Someone who doesn't want to list the .NET cultures can replace it.

@hishamco
Copy link
Member Author

I agree with you, may issue that I will find myself duplicating the code on both current implementations, if it's fine, I will update the PR ASAP

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.

5 participants