mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.Options;
|
|
using Squidex.Hosting;
|
|
|
|
namespace Squidex.Infrastructure
|
|
{
|
|
public sealed class LanguagesInitializer : IInitializable
|
|
{
|
|
private readonly LanguagesOptions options;
|
|
|
|
public LanguagesInitializer(IOptions<LanguagesOptions> options)
|
|
{
|
|
Guard.NotNull(options, nameof(options));
|
|
|
|
this.options = options.Value;
|
|
}
|
|
|
|
public Task InitializeAsync(
|
|
CancellationToken ct)
|
|
{
|
|
foreach (var (key, value) in options)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(value))
|
|
{
|
|
if (!Language.TryGetLanguage(key, out _))
|
|
{
|
|
Language.AddLanguage(key, value);
|
|
}
|
|
}
|
|
}
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
}
|
|
|