예제 #1
0
        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));
        }
예제 #2
0
 /* ----------------------------------------------------------------- */
 ///
 /// 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);
     });
 }
예제 #3
0
 /* ----------------------------------------------------------------- */
 ///
 /// 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);
     });
 }
예제 #4
0
        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));
        }
예제 #5
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 }
                );
        }
예제 #6
0
 public void Setup() => Locale.Configure();