public async Task Check_DownloadContent()
        {
            // Arrange
            var remoteConfig = new RemoteContentConfig
            {
                CacheDir = Path.GetTempPath()
            };

            var localConfig = new AssetsContentConfig
            {
                ResourceFolder = remoteConfig.CacheDir
            };

            if (!Directory.Exists(localConfig.ResourceFolder))
            {
                Directory.CreateDirectory(localConfig.ResourceFolder);
            }

            this.assetsTranslateContentClient =
                new AssetsTranslateContentClient(new PlatformComponentsFactory(), localConfig);
            var remoteTranslateContentClient = new RemoteTranslateContentClient(new PlatformComponentsFactory(), remoteConfig);
            var remoteLocale = new RemoteLocale("ru", RemoteTranslateContentClientTests.TestLocaleUrl);
            await remoteTranslateContentClient.GetContent(remoteLocale, null);

            var locales = this.assetsTranslateContentClient.GetLocales();

            // Act
            var content = await this.assetsTranslateContentClient.GetContent(locales.First(), null, CancellationToken.None);

            // Assert
            Assert.IsNotEmpty(content);
        }
Example #2
0
 public static ITranslateContentClient Create(
     IPlatformComponentsFactory platformComponentsFactory,
     RemoteContentConfig contentConfig,
     OfflineContentConfig offlineContentConfig)
 {
     return(new OfflineRemoteTranslateContentClient(platformComponentsFactory, contentConfig, offlineContentConfig));
 }
Example #3
0
 public OfflineRemoteTranslateContentClient(
     IPlatformComponentsFactory platformComponentsFactory,
     RemoteContentConfig contentConfig,
     OfflineContentConfig offlineContentConfig)
     : base(platformComponentsFactory, contentConfig)
 {
     this.offlineContentConfig = offlineContentConfig;
 }
Example #4
0
        public void SetUp()
        {
            var remoteConfig = new RemoteContentConfig
            {
                CacheDir = Path.GetTempPath()
            };

            this.remoteTranslateContentClient = new RemoteTranslateContentClient(
                new PlatformComponentsFactory(),
                remoteConfig);
            this.remoteLocale = new RemoteLocale("ru", TestLocaleUrl);
        }
        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();
        }
Example #7
0
        public void GetLanguages()
        {
            // Arrange
            var remoteConfig = new RemoteContentConfig
            {
                Locales =
                {
                    ["ru"] = TestLocaleUrl
                }
            };

            this.remoteTranslateContentClient = new RemoteTranslateContentClient(
                new PlatformComponentsFactory(),
                remoteConfig);

            // Act
            var locales = this.remoteTranslateContentClient.GetLocales();

            // Assert
            Assert.AreEqual(1, locales.Count);
        }
Example #8
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);
        }
Example #9
0
 public RemoteTranslateContentClient(IPlatformComponentsFactory platformComponentsFactory, RemoteContentConfig contentConfig)
 {
     this.contentConfig             = contentConfig;
     this.PlatformComponentsFactory = platformComponentsFactory;
     this.platformCacheFileManager  = platformComponentsFactory.CreateCacheFileManager();
 }
 public MvxLocalizationProvider(RemoteContentConfig config)
 {
     I18N.Initialize(config);
 }
Example #11
0
 public MvxYamlTextProvider(RemoteContentConfig config)
 {
     I18N.Initialize(config);
 }
Example #12
0
 public static void Initialize(RemoteContentConfig contentConfig, OfflineContentConfig offlineContentConfig)
 {
     InitializeInternal(TranslateContentClientFactory
                        .Create(CreatePlatformComponentsFactory(), contentConfig, offlineContentConfig));
 }