public static void Initialize(Action <InBuilder> builderAction) { var builder = new InBuilder(); builderAction(builder); Provider = builder.Build(); }
internal InProvider(InBuilder builder) { this.items = new Dictionary <string, Dictionary <string, string> >(); this.FallbackStrat = builder.FallbackStrategy; this.FallbackLanguage = builder.FallbackLanguage; this.CodeLookup = builder.CodeLookup; this.LoadItems(builder); }
public void ShouldLoadJsonFileFromEmbeddedResources() { var provider = new InBuilder() .AddJsonResources("BibliTech.I18n.Test.Embed.Json.", "text-") .SetFallbackLanguage("en") .Build(); this.AssertCommonData(provider); Assert.Equal(TestUtils.DataJsonEnLanguageCode, provider.FallbackLanguage); }
public static IServiceCollection AddI18n(this IServiceCollection services, Action <InBuilder> builderAction) { var inBuilder = new InBuilder(); builderAction(inBuilder); var provider = inBuilder.Build(); services.AddSingleton <IInProvider>(provider); return(services); }
private void LoadItems(InBuilder builder) { foreach (var input in builder.Inputs) { var code = input.LanguageCode; var langDict = this.items.GetOrCreate(code, _ => new Dictionary <string, string>()); var inputItems = input.Read(); foreach (var pair in inputItems) { langDict[pair.Key] = pair.Value; } } }