public static IServiceCollection AddGlobalization(this IServiceCollection services, [NotNull] string connectionString, [NotNull] string defaultCulture = "tr-TR", TranslationStoreProvider storeProvider = TranslationStoreProvider.Postgres) { var options = new TranslationOptionsBuilder() .SetProvider(storeProvider) .SetConnectionString(connectionString) .SetDefaultCulture(defaultCulture) .Build(); services.AddSingleton(options); services.AddScoped(typeof(TranslationStore), TranslationStoreMapper.MapProviderToSystemType(options.Provider)); services.AddScoped <ITranslator, Translator>(); services.AddMemoryCache(cacheOptions => { }); return(services); }
public ITranslationOptionsBuilder SetProvider(TranslationStoreProvider storeProvider) { _translationOptions.Provider = storeProvider; return(this); }
public static Type MapProviderToSystemType(TranslationStoreProvider provider) => TranslationStoreProviders[provider];