public void SetUp()
        {
            var remoteConfig = new RemoteContentConfig
            {
                CacheDir = Path.GetTempPath()
            };

            var hostAssembly = this.GetType().Assembly;

            this.offlineContentConfig = OfflineContentConfig.FromAssembly(hostAssembly, "en.yaml", "Locales");

            this.offlineRemoteTranslateContentClient = new OfflineRemoteTranslateContentClient(
                new PlatformComponentsFactory(),
                remoteConfig,
                this.offlineContentConfig);
        }
        protected override void ReloadLocale()
        {
            var remoteConfig = new RemoteContentConfig
            {
                Locales =
                {
                    { "ru", "https://raw.githubusercontent.com/kvandake/friendly-locale/master/Sample.Basic/FriendlyLocale.Sample.Core/Locales/ru.yaml" },
                    { "en", "https://raw.githubusercontent.com/kvandake/friendly-locale/master/Sample.Basic/FriendlyLocale.Sample.Core/Locales/en.yaml" }
                }
            };

            // assembly offline locale
            var assembly      = this.GetType().GetTypeInfo().Assembly;
            var offlineConfig = OfflineContentConfig.FromAssembly(assembly, "ru.yaml", "Locales");

            I18N.Initialize(remoteConfig, offlineConfig);
            this.ReloadItems();
        }
Exemplo n.º 3
0
        public async Task Chech_OfflineLocale()
        {
            // Arrange
            var hostAssembly  = this.GetType().Assembly;
            var offlineConfig = OfflineContentConfig.FromAssembly(hostAssembly, "en.yaml", "Locales");
            var remoteConfig  = new RemoteContentConfig
            {
                CacheDir = Path.GetTempPath()
            };

            I18N.Initialize(remoteConfig, offlineConfig);

            // Act
            var offlineLocale = I18N.Instance.GetLocale("offline");
            await I18N.Instance.ChangeLocale(offlineLocale);

            var value = I18N.Instance.Translate("ViewModel.Locale");

            // Assert
            Assert.NotNull(offlineLocale);
            Assert.AreEqual("en", value);
        }