From 0a3f893f22946319380da0914f2ab5b1e8e0e3e1 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Wed, 20 Mar 2019 23:44:29 +0100 Subject: [PATCH] V8: Improve plugin language handling (#4454) --- .../Composing/CompositionExtensions/Services.cs | 2 -- .../Implement/LocalizedTextServiceFileSources.cs | 10 +++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Composing/CompositionExtensions/Services.cs b/src/Umbraco.Core/Composing/CompositionExtensions/Services.cs index ead2524d80..0baefe104b 100644 --- a/src/Umbraco.Core/Composing/CompositionExtensions/Services.cs +++ b/src/Umbraco.Core/Composing/CompositionExtensions/Services.cs @@ -98,7 +98,6 @@ namespace Umbraco.Core.Composing.CompositionExtensions : appPlugins.GetDirectories() .SelectMany(x => x.GetDirectories("Lang")) .SelectMany(x => x.GetFiles("*.xml", SearchOption.TopDirectoryOnly)) - .Where(x => Path.GetFileNameWithoutExtension(x.FullName).Length == 5) .Select(x => new LocalizedTextServiceSupplementaryFileSource(x, false)); //user defined langs that overwrite the default, these should not be used by plugin creators @@ -106,7 +105,6 @@ namespace Umbraco.Core.Composing.CompositionExtensions ? Enumerable.Empty() : configLangFolder .GetFiles("*.user.xml", SearchOption.TopDirectoryOnly) - .Where(x => Path.GetFileNameWithoutExtension(x.FullName).Length == 10) .Select(x => new LocalizedTextServiceSupplementaryFileSource(x, true)); return new LocalizedTextServiceFileSources( diff --git a/src/Umbraco.Core/Services/Implement/LocalizedTextServiceFileSources.cs b/src/Umbraco.Core/Services/Implement/LocalizedTextServiceFileSources.cs index f620d31fe9..86913071fd 100644 --- a/src/Umbraco.Core/Services/Implement/LocalizedTextServiceFileSources.cs +++ b/src/Umbraco.Core/Services/Implement/LocalizedTextServiceFileSources.cs @@ -184,8 +184,12 @@ namespace Umbraco.Core.Services.Implement //now load in supplementary var found = _supplementFileSources.Where(x => { - var fileName = Path.GetFileName(x.File.FullName); - return fileName.InvariantStartsWith(culture.Name) && fileName.InvariantEndsWith(".xml"); + var extension = Path.GetExtension(x.File.FullName); + var fileCultureName = Path.GetFileNameWithoutExtension(x.File.FullName).Replace("_", "-").Replace(".user", ""); + return extension.InvariantEquals(".xml") && ( + fileCultureName.InvariantEquals(culture.Name) + || fileCultureName.InvariantEquals(culture.TwoLetterISOLanguageName) + ); }); foreach (var supplementaryFile in found) @@ -203,7 +207,7 @@ namespace Umbraco.Core.Services.Implement continue; } - if (xChildDoc.Root == null) continue; + if (xChildDoc.Root == null || xChildDoc.Root.Name != "language") continue; foreach (var xArea in xChildDoc.Root.Elements("area") .Where(x => ((string)x.Attribute("alias")).IsNullOrWhiteSpace() == false)) {