public void Configure() { var count = 0; using (Locale.Subscribe(e => ++ count)) { Locale.Configure(new Accessor <Language>(() => Language.Japanese, e => { })); Locale.Set(Language.English); Assert.That(Locale.Get(), Is.EqualTo(Language.Japanese)); Locale.Set(Language.Japanese); Assert.That(Locale.Get(), Is.EqualTo(Language.Japanese)); Locale.Set(Language.Japanese); Assert.That(Locale.Get(), Is.EqualTo(Language.Japanese)); Locale.Set(Language.German); Assert.That(Locale.Get(), Is.EqualTo(Language.Japanese)); Locale.Set(Language.Auto); Assert.That(Locale.Get(), Is.EqualTo(Language.Japanese)); } Assert.That(count, Is.EqualTo(3)); }
/* ----------------------------------------------------------------- */ /// /// SettingsFolder /// /// <summary> /// Initializes static fields. /// </summary> /// /* ----------------------------------------------------------------- */ static SettingsFolder() { Locale.Configure(e => { var src = e.ToCultureInfo(); var cmp = Properties.Resources.Culture?.Name; if (cmp.HasValue() && cmp.FuzzyEquals(src.Name)) { return(false); } Properties.Resources.Culture = src; return(true); }); }
/* ----------------------------------------------------------------- */ /// /// SettingsFolder /// /// <summary> /// Initializes static fields. /// </summary> /// /* ----------------------------------------------------------------- */ static SettingsFolder() { Locale.Configure(e => { var src = e.ToCultureInfo(); var cmp = Properties.Resources.Culture?.Name; var opt = StringComparison.InvariantCultureIgnoreCase; if (cmp.HasValue() && cmp.Equals(src.Name, opt)) { return(false); } Properties.Resources.Culture = src; return(true); }); }
public void Configure() { var count = 0; using (Locale.Subscribe(_ => ++ count)) { Locale.Configure(e => false); Locale.Set(Language.English); Locale.Set(Language.Japanese); Locale.Set(Language.Japanese); Locale.Set(Language.German); Locale.Set(Language.Auto); } Assert.That(count, Is.EqualTo(0)); }
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); Locale.Configure("zh-cn", "en-us"); routes.MapLocaleRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); routes.MapLocaleRedirectRoute( name: "RedirectToLocale", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); }
public void Setup() => Locale.Configure();