Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ricardo Marcelino 15 posts 73 karma points
    Oct 11, 2016 @ 15:59
    Ricardo Marcelino
    0

    LocalizedText service for Backoffice labels is returning empty

    Hello everyone!

    I made a manual upgrade from 7.2.8 to 7.3.8 and i encountered an issue with the backoffice. Here is a picture:

    Backoffice print with missing localized text

    I have cleared the TEMP folder and bumped the ClientDependency.config. I have checked my web.config and i have the current key:

    <add key="umbracoDefaultUILanguage" value="en" />
    

    When looking for the network calls, i see this url being called with success but returning a empty json:

    https://my.site.url/umbraco/LocalizedText
    

    I have checked and i have the en_us.xml and en.xml in the current place:

    /Umbraco/Config/Lang/en_us.xml;  /Umbraco/Config/Lang/en.xml
    

    I also went going forward with my updating, hoping to find the issue or fixing it with a new update (replaced Umbraco and Umbraco_Client folders totally), in this case to 7.5.3, but with no success.

    Any ideas why LocalizedText is returning empty? I have another site on the same version that i updated via nuget and dont have this issue.

    Best Regards!

  • Ricardo Marcelino 15 posts 73 karma points
    Oct 14, 2016 @ 15:44
    Ricardo Marcelino
    0

    Hello there!

    Nobody has any idea why this happens? Guess it isn't a recurring problem. I might try and debug through the source code to check what is being done here:

        /// <summary>
        /// Get the json localized text for a given culture or the culture for the current user
        /// </summary>
        /// <param name="culture"></param>
        /// <returns></returns>
        [HttpGet]
        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()
                    //current culture is set at the very beginning of each request
                    ? Thread.CurrentThread.CurrentCulture
                    : 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 };
        }
    

    Best Regards!

  • Ricardo Marcelino 15 posts 73 karma points
    Oct 19, 2016 @ 12:54
    Ricardo Marcelino
    0

    Hello again,

    Forcing this code, i managed to supply most of the missing resources:

    public JsonNetResult LocalizedText(string culture = "en")
    

    But some of the nodes in the trees dont load the text, even though the LocalizedText returns the values:

    Backoffice image 2

    Heres the response of LocalizedText, respective to Document Types (i suppose):

    "treeHeaders_documentTypes": "Document Types",
    

    Does this ring any bell to anyone? I'm feeling a bit overwhelmed with this.

    Best Regards

  • Ricardo Marcelino 15 posts 73 karma points
    Oct 24, 2016 @ 15:36
    Ricardo Marcelino
    0

    OK, so i come back with some news. Since nobody was able to have a quick response or notion of what the problem could be, in the tip of their fingertips, i debuged the source code for my version looking for an issue.

    So i arrived at this: https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Core/Services/LocalizedTextService.cs#L60

    When loading the Settings Tree and when entering in the above function, it would have culture defined to "pt-PT" for each node that doesn't load the title properly. For the other ones that show correctly, it would have culture defined to en-US. When i forced the culture to go from "pt-PT" to "en-US", it would load the full Tree properly.

    I went to my Global.cs file, under App_Code i found:

    public class Global : Umbraco.Web.UmbracoApplication
    {
        protected void Application_AcquireRequestState(object sender, EventArgs e)
        {
            #region override Culture
            CultureInfo culture = new CultureInfo("pt-PT");
            culture.DateTimeFormat.DateSeparator = "/";
            culture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
    
            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;
            #endregion
        }
    }
    

    So somebody forced, the culture for the UI, even though in the web.config we have the umbracoDefaultUILanguage set to "en". We've been using this since the initial 7.2.4 version without any issue or interferance.

    When commenting:

    Thread.CurrentThread.CurrentUICulture = culture;
    

    The Backoffice filled all the titles correctly.

    Either way, for me, it doesn't explain this... incosistent language behavior. Why do some tree nodes have pass different cultures to get a localized title value? I could understand if all titles were not being returned correctly because of "pt-PT" being passed but...

    Best Regards, Ricardo Marcelino

  • Abdul Hadi 2 posts 22 karma points
    5 days ago
    Abdul Hadi
    0

    Hello guys,

    I solved that problem changing this information below:

    I changed the value it was 4.6.1 to 4.5

    Best Regards, Abdul Hadi

Please Sign in or register to post replies

Write your reply to:

Draft