Ejemplo n.º 1
0
        public Benchmarks()
        {
            _localizer = new ObjectLocalizer
            {
                RequiredLanguages = new HashSet <string> {
                    "en", "zh", "ar", "es", "hi"
                },
                OptionalLanguages = new HashSet <string> {
                    "pt", "ru", "ja", "de", "el"
                }
            };

            _planets = CreatePlanets(1000);
        }
        /// <inheritdoc />
        public void Contextualize(ViewContext viewContext)
        {
            if (viewContext == null)
            {
                throw new ArgumentNullException(nameof(viewContext));
            }

            // Given a view path "/Views/Home/Index.cshtml" we want a baseName like "Views.Home.Index"
            var path = viewContext.ExecutingFilePath;

            if (string.IsNullOrEmpty(path))
            {
                path = viewContext.View.Path;
            }

            Debug.Assert(!string.IsNullOrEmpty(path), "Couldn't determine a path for the view");

            //Turns view path to a resource name without culture
            _viewPrefix = GetPrefix(path);

            _htmlLocalizer   = _htmlLocalizerFactory.Create(_viewPrefix, String.Empty);
            _objectLocalizer = _objectLocalizerFactory.Create(_viewPrefix, String.Empty);
        }
Ejemplo n.º 3
0
 public PlanetsController(DataContext context, IObjectLocalizer localizer)
 {
     _context   = context;
     _localizer = localizer;
 }
 public JsonFileObjectLocalizer(JsonFileObjectLocalizerFactory factory)
 {
     _localizer = factory.Create(typeof(TResource));
 }
Ejemplo n.º 5
0
 public BookEditModel(ApplicationDbContext dbContext, IObjectLocalizer objectLocalizer)
 {
     _dbContext       = dbContext;
     _objectLocalizer = objectLocalizer;
 }
Ejemplo n.º 6
0
 public LocalizableModelBinder(IObjectLocalizer localizer)
 {
     _localizer = localizer;
 }
Ejemplo n.º 7
0
 public IndexModel(ApplicationDbContext dbContext, IObjectLocalizer objectLocalizer, IHtmlLocalizer <IndexModel> htmlLocalizer)
 {
     _dbContext       = dbContext;
     _objectLocalizer = objectLocalizer;
     _htmlLocalizer   = htmlLocalizer;
 }
Ejemplo n.º 8
0
 public static T Localize <T>(this T item, IObjectLocalizer localizer, LocalizationDepth depth = LocalizationDepth.Shallow) where T : class, ILocalizable
 {
     return(localizer.Localize(item, depth));
 }
Ejemplo n.º 9
0
 public static IEnumerable <T> Localize <T>(this IEnumerable <T> items, IObjectLocalizer localizer, LocalizationDepth depth = LocalizationDepth.Shallow) where T : class, ILocalizable
 {
     return(localizer.Localize(items, depth));
 }
Ejemplo n.º 10
0
 public LocalizedEditor(IObjectLocalizer localizer)
 {
     _localizer = localizer;
 }