U4-7740 - Speed up the current user's culture lookup

Created by Shannon Deminick 14 Jan 2016, 14:50:27 Updated by Shannon Deminick 14 Jan 2016, 15:43:41

The current user's culture is set at the beginning of the request, always (on the current thread), so any calls to something like: Security.CurrentUser.GetUserCulture(Services.TextService) doesn't need to exist because we already know what it will be.

For example, this could be changed to just use the current thread culture.

        public JsonNetResult LocalizedText(string culture = null)
            var cultureInfo = string.IsNullOrWhiteSpace(culture)
                //if the user is logged in, get their culture, otherwise default to 'en'
                ? Security.IsAuthenticated()
                    ? Security.CurrentUser.GetUserCulture(Services.TextService)
                    : CultureInfo.GetCultureInfo("en")
                : CultureInfo.GetCultureInfo(culture);

            var textForCulture = Services.TextService.GetAllStoredValues(cultureInfo)
                //the dictionary returned is fine but the delimiter between an 'area' and a 'value' is a '/' but the javascript
                // in the back office requres the delimiter to be a '_' so we'll just replace it
                .ToDictionary(key => key.Key.Replace("/", "_"), val => val.Value);

            return new JsonNetResult { Data = textForCulture, Formatting = Formatting.Indented };


Shannon Deminick 14 Jan 2016, 15:43:41

rev: 7958b5fcb1a890dccd928beb3c257da66e1e0196

Priority: Normal

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.3.5

Sprint: Sprint 6

Story Points: