Merge pull request #12206 from KevinJump/v9/localizedtext-via-fileprovider
Get lang files via FileProviders (and support Razor Class Libraries)
This commit is contained in:
@@ -76,31 +76,13 @@ namespace Umbraco.Cms.Infrastructure.DependencyInjection
|
||||
private static LocalizedTextServiceFileSources SourcesFactory(IServiceProvider container)
|
||||
{
|
||||
var hostingEnvironment = container.GetRequiredService<IHostingEnvironment>();
|
||||
var globalSettings = container.GetRequiredService<IOptions<GlobalSettings>>().Value;
|
||||
var mainLangFolder = new DirectoryInfo(hostingEnvironment.MapPathContentRoot(WebPath.Combine(Constants.SystemDirectories.Umbraco, "config", "lang")));
|
||||
var appPlugins = new DirectoryInfo(hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.AppPlugins));
|
||||
var configLangFolder = new DirectoryInfo(hostingEnvironment.MapPathContentRoot(WebPath.Combine(Constants.SystemDirectories.Config, "lang")));
|
||||
|
||||
var pluginLangFolders = appPlugins.Exists == false
|
||||
? Enumerable.Empty<LocalizedTextServiceSupplementaryFileSource>()
|
||||
: appPlugins.GetDirectories()
|
||||
// Check for both Lang & lang to support case sensitive file systems.
|
||||
.SelectMany(x => x.GetDirectories("?ang", SearchOption.AllDirectories).Where(x => x.Name.InvariantEquals("lang")))
|
||||
.SelectMany(x => x.GetFiles("*.xml", SearchOption.TopDirectoryOnly))
|
||||
.Select(x => new LocalizedTextServiceSupplementaryFileSource(x, false));
|
||||
|
||||
// user defined langs that overwrite the default, these should not be used by plugin creators
|
||||
var userLangFolders = configLangFolder.Exists == false
|
||||
? Enumerable.Empty<LocalizedTextServiceSupplementaryFileSource>()
|
||||
: configLangFolder
|
||||
.GetFiles("*.user.xml", SearchOption.TopDirectoryOnly)
|
||||
.Select(x => new LocalizedTextServiceSupplementaryFileSource(x, true));
|
||||
|
||||
return new LocalizedTextServiceFileSources(
|
||||
container.GetRequiredService<ILogger<LocalizedTextServiceFileSources>>(),
|
||||
container.GetRequiredService<AppCaches>(),
|
||||
mainLangFolder,
|
||||
pluginLangFolders.Concat(userLangFolders));
|
||||
container.GetServices<LocalizedTextServiceSupplementaryFileSource>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user