private void WriteTranslationAndNotify(IResourceFileHelper fileHelper, string translatedValue, KeyValuePair<string, string> sourceValue) { fileHelper.WriteNameValuePairToTarget(sourceValue.Key, translatedValue, true); translationNotification(new TranslatedItem { DataKey = sourceValue.Key, EnglishValue = sourceValue.Value, Translation = translatedValue }); }
public void TranslateWorkbook(IResourceFileHelper resourceFileHelper, string excelFile, int selectedWorksheet) { var excelTranslations = GetAllValues(excelFile, selectedWorksheet); foreach (var translationResult in excelTranslations) { var keyValue = translationResult.Key; var englishValue = translationResult.EnglishValue; var translatedValue = translationResult.Translation; if (String.IsNullOrWhiteSpace(translatedValue)) continue; if (String.IsNullOrWhiteSpace(keyValue) == false) { resourceFileHelper.WriteNameValuePairToTarget(keyValue, translatedValue, true); translationNotification(new TranslatedItem { DataKey = keyValue, EnglishValue = englishValue, Translation = translatedValue }); continue; } Dictionary<String, String> sourceValues = resourceFileHelper.GetNameValuesFromSource(englishValue); if (sourceValues == null || sourceValues.Any() == false) { translationNotification(new TranslatedItem { DataKey = "WARNING", EnglishValue = englishValue, Translation = "No translation can be made.", Comment = "No Source Key could be found!" }); continue; } if (sourceValues.Count() == 1) { var uniqueValue = sourceValues.Single(); resourceFileHelper.WriteNameValuePairToTarget(uniqueValue.Key, translatedValue, true); translationNotification(new TranslatedItem { DataKey = uniqueValue.Key, EnglishValue = uniqueValue.Value, Translation = translatedValue }); continue; } if (sourceValues.Count() > 1) { var cancelOperation = TranslateMultipleKeyValues(resourceFileHelper, sourceValues, englishValue, translatedValue); if (cancelOperation) break; } } }