コード例 #1
0
ファイル: Fluin.cs プロジェクト: BibliTech/I18n
        public static void Initialize(Action <InBuilder> builderAction)
        {
            var builder = new InBuilder();

            builderAction(builder);

            Provider = builder.Build();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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;
                }
            }
        }