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); }
public static ITranslateContentClient Create( IPlatformComponentsFactory platformComponentsFactory, RemoteContentConfig contentConfig, OfflineContentConfig offlineContentConfig) { return(new OfflineRemoteTranslateContentClient(platformComponentsFactory, contentConfig, offlineContentConfig)); }
public OfflineRemoteTranslateContentClient( IPlatformComponentsFactory platformComponentsFactory, RemoteContentConfig contentConfig, OfflineContentConfig offlineContentConfig) : base(platformComponentsFactory, contentConfig) { this.offlineContentConfig = offlineContentConfig; }
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(); }
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); }
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); }
public RemoteTranslateContentClient(IPlatformComponentsFactory platformComponentsFactory, RemoteContentConfig contentConfig) { this.contentConfig = contentConfig; this.PlatformComponentsFactory = platformComponentsFactory; this.platformCacheFileManager = platformComponentsFactory.CreateCacheFileManager(); }
public MvxLocalizationProvider(RemoteContentConfig config) { I18N.Initialize(config); }
public MvxYamlTextProvider(RemoteContentConfig config) { I18N.Initialize(config); }
public static void Initialize(RemoteContentConfig contentConfig, OfflineContentConfig offlineContentConfig) { InitializeInternal(TranslateContentClientFactory .Create(CreatePlatformComponentsFactory(), contentConfig, offlineContentConfig)); }