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
Fixes #12904 UmbracoHelper.GetDictionaryValue defaults to en-US when used in non-front end code #12942
Conversation
Hi there @uppercuut, thank you for this contribution! 👍 While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
Hi @uppercuut Just going through some of the longer running PRs, and noticed this one has been open for a while with no reply, so firstly, apologies for that. Just wanted to let you know that I've flagged it internally to get it reviewed in one of the upcoming sprints. Best wishes, Emma 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @uppercuut, thanks a lot for the PR, it's greatly appreciated.
Over all it looks great, however, I'm afraid we can't change the default culture retuned by the Culture
property since this is breaking.
I've taken the liberty of adding a small commit to help the PR better suit our internal code style (we generally don't use this.
😄)
Again thanks a lot 😄
/// Returns the defualt umbraco's back office culture | ||
/// </summary> | ||
public CultureInfo Culture => _specificCulture ?? Thread.CurrentThread.CurrentUICulture; | ||
public CultureInfo Culture => _specificCulture ?? new CultureInfo( _localizationService.GetDefaultLanguageIsoCode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid we can't really introduce this change in minor since this is behaviorally breaking, unfortunately. Since this could suddenly change the culture of people's UmbracoCultureDictionary
, potentially breaking the code.
However, I do agree that it would make more sense to default to the default language instead, so it may be one for a major 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello , thanks for replying ,
honestly I don't remember what is this PR for , so I give you full liberty over it. tweak or change what ever u like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's been quite a while, sorry about that, but I'll go ahead and undo this specific part, and then move that to V13. then we can merge the rest of this PR 😄
Prerequisites
Brief : The main issue that the Method called
GetDictionaryValue
do not respect the default Umbraco culture//or send a parametric culture specification.original issue #12904
Description
What's Changed :
### 1
DefaultCultureDictionary
class :this class has a property called
Culture
which were behaving as follows :public CultureInfo Culture => _specificCulture ?? Thread.CurrentThread.CurrentUICulture;
though this is an umbraco-framework class it takes the culture of the entire application. hence if the consumer wants to change the default umbraco culture he has to change the entire solution's culture and I don't think its a good idea because we don't want to couple an entire solution which might use other frameworks/library who are culture dependent.
_long story short : _ I think the default culture of Umbraco should be the default Umbraco Context culture which is the default back office culture.
so (I think) it would be better if it was changed to :
public CultureInfo Culture => _specificCulture ?? new CultureInfo( _localizationService.GetDefaultLanguageIsoCode());
### 2
I renamed the method
GetDictionaryValue
which is overloaded with thealtText
toGetDictionaryValueOrDefault
and goes by the signature :
string GetDictionaryValueOrDefault(string key, string altText)
it's Microsoft convention after all.
### 3
I added two new overloads in
UmbracoHelper
clss goes the the signaturesstring GetDictionaryValueOrDefault(string key, CultureInfo specificCulture, string altText)
string? GetDictionaryValue(string key, CultureInfo specificCulture)
### 4
Added one overload into the
ICultureDictionaryFactory
which takes thespecificCulture
and in the implementation I just calledDefaultCultureDictionary
with the constructor that takes thespecificCulture
as parameters.