Example #1
0
        private void PushForLocale(LocaleInfo locale, LocalizationDataManager localizationDataManager)
        {
            var client = GetPhraseAppClient();

            var localizationNamespacesToPush = localizationDataManager.GetNamespaces(locale.Name).Where(ns => ns.DoesHaveData());

            var localeData = client.Pull(locale.Id);

            foreach (var namespaceToPush in localizationNamespacesToPush)
            {
                var addedKeys = namespaceToPush.GetAddedKeys(localeData);

                if (!addedKeys.Any())
                {
                    Console.WriteLine($"Nothing to push in namespace {namespaceToPush.Name}: {namespaceToPush.DataFilePath}");
                    continue;
                }

                Console.WriteLine($"Pushing {namespaceToPush.Name}: {namespaceToPush.DataFilePath}");

                namespaceToPush.CheckData();

                client.Push(
                    locale.Id,
                    namespaceToPush.Name,
                    namespaceToPush.DataFilePath);
            }
        }
        private void PullForLocale(LocaleInfo locale, LocalizationDataManager localizationDataManager)
        {
            var client = GetPhraseAppClient();

            var sourceLocalizationData = client.Pull(locale.Id);

            foreach (var namespaceInfo in localizationDataManager.GetNamespaces(locale.Name))
            {
                namespaceInfo.ApplyNewTranslations(sourceLocalizationData);
            }
        }
Example #3
0
        private static (IEnumerable <string> AddedKeys, IEnumerable <string> RemovedKeys) CheckKeysDiff(
            LocalizationDataManager localizationDataManager,
            LocaleInfo locale,
            IReadOnlyDictionary <string, string> localeData)
        {
            var addedKeys   = new List <string>();
            var removedKeys = new List <string>();

            Console.WriteLine("Performing diff check");
            foreach (var localizationNamespace in localizationDataManager.GetNamespaces(locale.Name))
            {
                var addedKeysToCurrentNamespace     = localizationNamespace.GetAddedKeys(localeData);
                var removedKeysFromCurrentNamespace = localizationNamespace.RemovedKeys(localeData);

                addedKeys.AddRange(addedKeysToCurrentNamespace);
                removedKeys.AddRange(removedKeysFromCurrentNamespace);
            }

            return(addedKeys, removedKeys);
        }