Exemplo n.º 1
0
 public static ITranslateContentClient Create(
     IPlatformComponentsFactory platformComponentsFactory,
     RemoteContentConfig contentConfig,
     OfflineContentConfig offlineContentConfig)
 {
     return(new OfflineRemoteTranslateContentClient(platformComponentsFactory, contentConfig, offlineContentConfig));
 }
Exemplo n.º 2
0
 public OfflineRemoteTranslateContentClient(
     IPlatformComponentsFactory platformComponentsFactory,
     RemoteContentConfig contentConfig,
     OfflineContentConfig offlineContentConfig)
     : base(platformComponentsFactory, contentConfig)
 {
     this.offlineContentConfig = offlineContentConfig;
 }
        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.º 5
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);
        }
Exemplo n.º 6
0
 public OfflineLocale(OfflineContentConfig config)
 {
     this.config = config;
 }
Exemplo n.º 7
0
 public static void Initialize(RemoteContentConfig contentConfig, OfflineContentConfig offlineContentConfig)
 {
     InitializeInternal(TranslateContentClientFactory
                        .Create(CreatePlatformComponentsFactory(), contentConfig, offlineContentConfig));
 }