Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)
13.1.0
Bug summary
When using the Umbraco.GetDictionaryValue the culture dictionary is cached, if you use the overload to specify you want a dictionary value for a specific culture, then that culture is cached, and all future method calls will return values for that culture.
Specifics
I have a language switcher, and want to display a dictionary defined value for that culture
<ul>
@foreach (var (culture, _) in Model.Cultures.Where(x => !string.Equals(x.Key, CultureInfo.CurrentCulture.Name, StringComparison.InvariantCultureIgnoreCase)))
{
<li><a href="@Model.Url(culture)">@Umbraco.GetDictionaryValue($"LanguageSwitcher.{culture}", CultureInfo.GetCultureInfo(culture))</a></li>
}
</ul>
Because I am specifying a culture in the GetDictionaryValue call, all future calls will use the culture of the last culture in the loop.
Steps to reproduce
On an Umbraco install with multiple configured languages, create a dictionary item and specify values for all cultures.
- In a view call
Umbraco.GetDictionaryValue("ItemKey") and observe the value is that of the current culture
- Call
Umbraco.GetDictionaryValue("ItemKey", CultureInfo.GetCultureInfo("you-other-culture")) and observe that the value is the specified culture.
- Call
Umbraco.GetDictionaryValue("ItemKey") once more, and observe that the value is the previously specified culture, and NOT the current culture.
e.g
<p>@Umbraco.GetDictionaryValue("FormInput.Email")</p> // E-mail
<p>@Umbraco.GetDictionaryValue("FormInput.Email", CultureInfo.GetCultureInfo("sv"))</p> // E-postadress
<p>@Umbraco.GetDictionaryValue("FormInput.Email")</p> // E-postadress. All future method calls will be "sv" culture
Expected result / actual result
Expected:
After specifying a culture for one method call, future calls with no culture specified should return values for the current culture
Actual:
After specifying a culture for one method call, future calls with no culture specified returns values for the culture supplied in whatever culture was used in a previous call.
Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)
13.1.0
Bug summary
When using the
Umbraco.GetDictionaryValuethe culture dictionary is cached, if you use the overload to specify you want a dictionary value for a specific culture, then that culture is cached, and all future method calls will return values for that culture.Specifics
I have a language switcher, and want to display a dictionary defined value for that culture
Because I am specifying a culture in the
GetDictionaryValuecall, all future calls will use the culture of the last culture in the loop.Steps to reproduce
On an Umbraco install with multiple configured languages, create a dictionary item and specify values for all cultures.
Umbraco.GetDictionaryValue("ItemKey")and observe the value is that of the current cultureUmbraco.GetDictionaryValue("ItemKey", CultureInfo.GetCultureInfo("you-other-culture"))and observe that the value is the specified culture.Umbraco.GetDictionaryValue("ItemKey")once more, and observe that the value is the previously specified culture, and NOT the current culture.e.g
Expected result / actual result
Expected:
After specifying a culture for one method call, future calls with no culture specified should return values for the current culture
Actual:
After specifying a culture for one method call, future calls with no culture specified returns values for the culture supplied in whatever culture was used in a previous call.