public static Localization Localization(this TRouteCollection routeCollection,
			Action<Configuration> configurationAction)
		{
			Configuration configuration = new Configuration();
			configurationAction.Invoke(configuration);

			return new Localization(configuration);
		}
Пример #2
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");


            routes.MapMvcAttributeRoutes(Localization.LocalizationDirectRouteProvider);

            ISet <string> acceptedCultures = new HashSet <string>()
            {
                "tr", "en"
            };
            string DefaultCulture = "en";
            var    configuration  = new RouteLocalization.Mvc.Setup.Configuration
            {
                DefaultCulture           = DefaultCulture,
                AcceptedCultures         = acceptedCultures,
                AttributeRouteProcessing =
                    AttributeRouteProcessing.AddAsNeutralAndDefaultCultureRoute,
                AddCultureAsRoutePrefix = true
            };

            var localization = new Localization(configuration); //create a localization variable

            localization.TranslateInitialAttributeRoutes();
            localization.ForCulture("tr")
            .ForController <HomeController>()
            .ForAction(x => x.About())
            .AddTranslation("Hakkında")
            .ForAction(x => x.Contact())
            .AddTranslation("İletişim");
            CultureSensitiveHttpModule.GetCultureFromHttpContextDelegate =
                Localization.DetectCultureFromBrowserUserLanguages(acceptedCultures,
                                                                   DefaultCulture);


            routes.MapRoute(
                name: "Language",
                url: "{controller}/{action}",
                defaults: new { controller = "Language", action = "ChangeLanguage" }
                );
        }
		public static Localization Localization(this TRouteCollection routeCollection, Configuration configuration)
		{
			return new Localization(configuration);
		}