예제 #1
0
        /// <summary>
        /// Add XLocalizer with database support using the built-in entity models
        /// </summary>
        /// <typeparam name="TContext">Application db context</typeparam>
        /// <param name="builder">builder</param>
        /// <returns></returns>
        public static IMvcBuilder AddXDbLocalizer <TContext>(this IMvcBuilder builder)
            where TContext : DbContext
        {
            var ops = new XLocalizerOptions();

            return(builder
                   .AddXDbLocalizer <TContext, DummyTranslator, XDbResource>(o => o = ops));
        }
예제 #2
0
        /// <summary>
        /// Initialize a new instance of <see cref="EFDbResourceExporter{TContext}"/>
        /// </summary>
        /// <param name="context"></param>
        /// <param name="options"></param>
        /// <param name="loggerFactory"></param>
        public EFDbResourceExporter(TContext context, IOptions <XLocalizerOptions> options, ILoggerFactory loggerFactory)
        {
            _context = context ?? throw new NotImplementedException(nameof(context));

            _options = options.Value;

            _loggerFactory = loggerFactory;

            _logger = loggerFactory.CreateLogger <EFDbResourceExporter <TContext> >();
        }
예제 #3
0
        /// <summary>
        /// Add XLocalizer with DB support using customized entity models,
        /// and use defined translation service type
        /// </summary>
        /// <typeparam name="TContext">DbContext</typeparam>
        /// <typeparam name="TTranslator">Translation service</typeparam>
        /// <typeparam name="TResource">Type of resource DbEntity</typeparam>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static IMvcBuilder AddXDbLocalizer <TContext, TTranslator, TResource>(this IMvcBuilder builder)
            where TContext : DbContext
            where TTranslator : ITranslator
            where TResource : class, IXDbResource, new()
        {
            var ops = new XLocalizerOptions();

            return(builder
                   .AddXDbLocalizer <TContext, TTranslator, TResource>(o => o = ops));
        }
예제 #4
0
 /// <summary>
 /// Initialize a new instance of DbStringLocalizer
 /// </summary>
 /// <param name="options"></param>
 /// <param name="provider"></param>
 /// <param name="translatorFactory"></param>
 /// <param name="cache"></param>
 /// <param name="loggerFactory"></param>
 /// <param name="localizationOptions"></param>
 public DbStringLocalizer(IDbResourceProvider provider,
                          ITranslatorFactory translatorFactory,
                          ExpressMemoryCache cache,
                          IOptions <XLocalizerOptions> options,
                          IOptions <RequestLocalizationOptions> localizationOptions,
                          ILoggerFactory loggerFactory)
 {
     _options      = options.Value;
     _provider     = provider;
     _translator   = translatorFactory.Create();
     _cache        = cache;
     _logger       = loggerFactory.CreateLogger <DbStringLocalizer <TResource> >();
     _transCulture = options.Value.TranslateFromCulture ?? localizationOptions.Value.DefaultRequestCulture.Culture.Name;
 }
 /// <summary>
 /// Initialize a new instance of <see cref="XmlResourceExporter"/>
 /// </summary>
 public XmlResourceExporter(IOptions <XLocalizerOptions> options, ILoggerFactory loggerFactory)
 {
     _options       = options.Value;
     _logger        = loggerFactory.CreateLogger <XmlResourceExporter>();
     _loggerFactory = loggerFactory;
 }
예제 #6
0
 /// <summary>
 /// Initialize a new instance of <see cref="XmlResourceProvider"/>
 /// </summary>
 public XmlResourceProvider(IOptions <XLocalizerOptions> options,
                            ILogger <XmlResourceProvider> logger)
 {
     _logger  = logger;
     _options = options.Value;
 }
예제 #7
0
 /// <summary>
 /// Initialize a new instance of <see cref="ResxResourceProvider"/>
 /// </summary>
 /// <param name="options"></param>
 /// <param name="logger"></param>
 public ResxResourceProvider(IOptions <XLocalizerOptions> options,
                             ILogger <ResxResourceProvider> logger)
 {
     _options = options.Value;
     _logger  = logger;
 }
예제 #8
0
 /// <summary>
 /// Create a new instance of ExpressMemoryCache
 /// </summary>
 public ExpressMemoryCache(IMemoryCache cache, IOptions <MemoryCacheEntryOptions> entryOptions, IOptions <XLocalizerOptions> options)
 {
     _cache    = cache;
     _entryOps = entryOptions.Value;
     _options  = options.Value;
 }