Exemple #1
0
        private LocalisationEngine engine; //keep a reference to avoid GC of the engine

        public override void Reset()
        {
            base.Reset();

            var config = new FakeFrameworkConfigManager();

            engine = new LocalisationEngine(config);

            engine.AddLanguage("en", new FakeStorage());
            engine.AddLanguage("zh-CHS", new FakeStorage());
            engine.AddLanguage("ja", new FakeStorage());

            Add(new FillFlowContainer <SpriteText>
            {
                Anchor       = Anchor.Centre,
                Origin       = Anchor.Centre,
                Direction    = FillDirection.Vertical,
                Spacing      = new Vector2(0, 10),
                Padding      = new MarginPadding(10),
                AutoSizeAxes = Axes.Both,
                Children     = new[]
                {
                    new SpriteText
                    {
                        Text     = "Not localisable",
                        TextSize = 48,
                        Colour   = Color4.White
                    },
                    new SpriteText
                    {
                        Current  = engine.GetLocalisedString("localisable"),
                        TextSize = 48,
                        Colour   = Color4.White
                    },
                    new SpriteText
                    {
                        Current  = engine.GetUnicodePreference("Unicode on", "Unicode off"),
                        TextSize = 48,
                        Colour   = Color4.White
                    },
                    new SpriteText
                    {
                        Current  = engine.GetUnicodePreference(null, "I miss unicode"),
                        TextSize = 48,
                        Colour   = Color4.White
                    },
                    new SpriteText
                    {
                        Current  = engine.Format("{0}", DateTime.Now),
                        TextSize = 48,
                        Colour   = Color4.White
                    },
                }
            });

            AddStep("English", () => config.Set(FrameworkSetting.Locale, "en"));
            AddStep("Japanese", () => config.Set(FrameworkSetting.Locale, "ja"));
            AddStep("Simplified Chinese", () => config.Set(FrameworkSetting.Locale, "zh-CHS"));
            AddToggleStep("ShowUnicode", b => config.Set(FrameworkSetting.ShowUnicode, b));
        }
Exemple #2
0
            public LocalisableTestContainer()
            {
                var config = new FakeFrameworkConfigManager();

                localisation = new LocalisationManager(config);
                localisation.AddLanguage("en", new FakeStorage("en"));
                localisation.AddLanguage("ja", new FakeStorage("ja"));

                config.Set(FrameworkSetting.Locale, "ja");
            }