U4-6665 - No Culture Found Breaking Localization After Umbraco Upgrade

Created by Nicholas Westby 29 May 2015, 16:33:18 Updated by Thomas Beckert 17 Jan 2018, 08:46:54

Relates to: U4-6307

After Upgrading from Umbraco 7.0.4 to 7.2.5, I am seeing this on the login screen: !login.png!

Note that I've deleted everything in the App_Data/TEMP folder, recycled the app pool, cleared my browser cache, restarted my computer, and rebuilt my Visual Studio solution a number of times. I also noticed this in my Umbraco log file:

WARN Umbraco.Core.Services.LocalizedTextService - [Thread 13] The culture specified was not found in any configured sources for this service

Note that that message comes from several places in this file: https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Core/Services/LocalizedTextService.cs#L100

Also note that it's supposed to contain the culture, but instead you see an empty string (i.e., "the culture specified [CULTURE MISSING] was not found").

5 Attachments


Sebastiaan Janssen 29 May 2015, 16:41:07

Check your Umbraco\config\lang\en.xml (or en_us.xml). It start with something like:

<language alias="en" intName="English (UK)" localName="English (UK)" lcid="" culture="en-GB">

The culture attribute is what's being used in the LocalizedTextService.

Nicholas Westby 29 May 2015, 16:57:32


My en.xml has this: My en_us.xml has this: My web.config has this:

Note that the problem is unlikely the XML files in the Lang folder, as the error log shows that the culture isn't even being propagated in the first place (i.e., it wouldn't be able to lookup the culture by culture code, as the culture code isn't even being recognized in the first place). Phrased another way, there is no "culture specified". I have no idea why that might be.

Sebastiaan Janssen 29 May 2015, 17:18:31

The culture is coming from : https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Web/Editors/BackOfficeController.cs#L69

Try and get the culture by dropping CultureInfo.GetCultureInfo("en") in a view and seeing if that works.

Also check in an incognito browser window, maybe an old cookie is setting a context but not giving you a culture as you're not actually logged in.

Nicholas Westby 29 May 2015, 18:39:54

@sebastiaan The result of calling GetCultureInfo was "en", as you can see here: !quick-watch.png!

Tried an incognito window and saw the same thing: !incognito.png!

Might the problem be that it is returning "en" rather then "en-US" or "en-GB"?

Nicholas Westby 29 May 2015, 18:50:00

I tried something that seems to support my theory. I copied "en_us.xml" to "en_plain.xml" and changed the second line to read:

Notice the culture is set to "en" (rather than "en-US" or "en-GB"). Then when I visited the login page, I saw this: !hacked.png! It still seems to be having trouble with a couple placeholders, but at least a few of them got localized. Seems like this is related to the inconsistency within Umbraco with regard to short/long culture codes (e.g., "en" / "en-GB").

Sebastiaan Janssen 29 May 2015, 19:55:14

Here's how it works: <add key="umbracoDefaultUILanguage" value="en" /> will resolve to en.xml (due to inconsistencies in the past), that will then look for the alias (en) and return the culture (en-GB by default).

You can inspect the following classes to follow the logic: You have a culture ("en") so you end up here: https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Core/Services/LocalizedTextService.cs#L88 Which leads to: https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Core/Services/LocalizedTextService.cs#L173 Which leads to: https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Core/Services/LocalizedTextServiceFileSources.cs

(LocalizedTextService is initialized here, pointing to the folder with the languages in it: https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Core/Services/ServiceContext.cs#L131)

I have absolutely no idea how <add key="umbracoDefaultUILanguage" value="en" /> could ever resolve to en_plain.xml.

Happy to admit defeat if you can spot the error in the logic, I can't see it. :)

Might be a good idea to set umbracoDefaultUILanguage to en-US as when it's set to a proper 4-letter culture it doesn't try to get the culture from the language files to start with.

Nicholas Westby 30 May 2015, 00:18:50

@sebastiaan The problem is this null check: https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Web/Editors/BackOfficeController.cs#L68 !null-check.png!

It's checking against null, but the value is an empty string (or whitespace... not sure). I replaced that null check on my local with this and it seemed to fix my problem: string.IsNullOrWhiteSpace(culture)

I'll submit a pull request in a couple hours.

Nicholas Westby 30 May 2015, 04:03:54

Submitted pull request: https://github.com/umbraco/Umbraco-CMS/pull/698

Nicholas Westby 01 Jun 2015, 15:47:56

@sebastiaan Mystery solved. If you are curious, I think I figured out why that culture was an empty string rather than null on the project I'm working on. I found this class: public class TrimModelBinder : IModelBinder { public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { ValueProviderResult valueResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); if (valueResult == null || string.IsNullOrEmpty(valueResult.AttemptedValue)) return string.Empty; return valueResult.AttemptedValue.Trim(); } }

Basically, it seems to be converting null request values to an empty string. I may be able to modify this to get around the issue, but I would also recommend accepting the pull request as it adds an extra safeguard for situations like this.

Shannon Deminick 02 Jun 2015, 19:28:43

Looking at this now

Shannon Deminick 02 Jun 2015, 19:29:27

The fix looks fine, have pulled it in

Nicholas Westby 02 Jun 2015, 19:56:35

Happy day! Thanks, @Shandem.

Thomas Beckert 17 Jan 2018, 08:46:54

Hi. I reencountered the problem after upgrading from 7.6.2 to 7.7.8 First call of the backend will not translate the placeholders. If I add the en_plain.xml, some textes will be loaded and replaced (not all!). Very weired. Any idea how to fix that?

Priority: Minor

Type: Bug

State: Fixed


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 7.2.5

Due in version: 7.2.6


Story Points: