public void AddTranslationItem(TranslationItem translationItem) { if (string.IsNullOrEmpty(translationItem.Name)) throw new InvalidOperationException("Cannot add translationitem without name"); translationItems.Add(translationItem); }
public void AddTranslationItemIfNotExist(TranslationItem translationItem) { if (string.IsNullOrEmpty(translationItem.Name)) { throw new InvalidOperationException("Cannot add translationitem without name"); } TranslationItem ti = GetTranslationItem(translationItem.Name, translationItem.Property); if (ti == null) { if (translationItem.Property == "ToolTipText") { ti = GetTranslationItem(translationItem.Name, "Text"); if (ti == null || translationItem.Value != ti.Value) { translationItems.Add(translationItem); } } else { translationItems.Add(translationItem); } } else { Debug.Assert(ti.Value == translationItem.Value); } }
public void AddTranslationItem(TranslationItem translationItem) { if (string.IsNullOrEmpty(translationItem.Name)) { throw new InvalidOperationException("Cannot add translationitem without name"); } translationItems.Add(translationItem); }
public void AddTranslationItemIfNotExist(TranslationItem translationItem) { if (string.IsNullOrEmpty(translationItem.Name)) throw new InvalidOperationException("Cannot add translationitem without name"); TranslationItem ti = GetTranslationItem(translationItem.Name, translationItem.Property); if (ti == null) translationItems.Add(translationItem); else Debug.Assert(ti.Value == translationItem.Value); }
public string TranslateItem(string category, string item, string property, string defaultValue) { TranslationCategory tc = GetTranslationCategory(category); if (tc == null) { return(defaultValue); } TranslationItem ti = tc.GetTranslationItem(item, property); return(ti == null || string.IsNullOrEmpty(ti.Value) ? defaultValue : ti.Value); }
public string TranslateItem(string category, string item, string property, string defaultValue) { TranslationCategory tc = GetTranslationCategory(category); if (tc == null) { return(defaultValue); } TranslationItem ti = tc.GetTranslationItem(item, property); if (ti == null) { return(defaultValue); } else { return(ti.Value); } }
public TranslationItemWithCategory(string category, TranslationItem item) { Category = category; _item = item; }
public TranslationItemWithCategory() { _item = new TranslationItem(); }
private void SaveAs() { var foreignTranslation = new Translation { GitExVersion = GitCommands.Settings.GitExtensionsVersionString, LanguageCode = GetSelectedLanguageCode() }; foreach (TranslateItem translateItem in translate) { string value = translateItem.TranslatedValue ?? String.Empty; TranslationItem ti = new TranslationItem(translateItem.Name, translateItem.Property, translateItem.NeutralValue, value); ti.Status = translateItem.Status; if (ti.Status == TranslationType.Obsolete && (String.IsNullOrEmpty(value) || String.IsNullOrEmpty(translateItem.NeutralValue))) continue; if (string.IsNullOrEmpty(value)) { if (ti.Status == TranslationType.Translated || ti.Status == TranslationType.New) ti.Status = TranslationType.Unfinished; } else { // TODO: Support in form if (ti.Status == TranslationType.Unfinished) ti.Status = TranslationType.Translated; } foreignTranslation.FindOrAddTranslationCategory(translateItem.Category).AddTranslationItem(ti); } using (var fileDialog = new SaveFileDialog { Title = saveAsText.Text, FileName = translations.Text + ".xml", Filter = saveAsTextFilter.Text + "|*.xml", DefaultExt = ".xml", AddExtension = true }) { if (fileDialog.ShowDialog(this) == DialogResult.OK) { TranslationSerializer.Serialize(foreignTranslation, fileDialog.FileName); changesMade = false; } } }
private void SaveAs() { var foreignTranslation = new Translation { LanguageCode = GetSelectedLanguageCode() }; if (foreignTranslation.LanguageCode != null) { foreach (TranslateItem translateItem in translate) { //Item is not translated (yet), skip it if (string.IsNullOrEmpty(translateItem.TranslatedValue)) continue; TranslationItem ti = new TranslationItem(translateItem.Name, translateItem.Property, translateItem.TranslatedValue); foreignTranslation.FindOrAddTranslationCategory(translateItem.Category).AddTranslationItem(ti); } } else { // English language foreach (TranslateItem translateItem in translate) { TranslationItem ti = new TranslationItem(translateItem.Name, translateItem.Property, translateItem.NeutralValue); foreignTranslation.FindOrAddTranslationCategory(translateItem.Category).AddTranslationItem(ti); } } var fileDialog = new SaveFileDialog { Title = saveAsText.Text, FileName = translations.Text + ".xml", Filter = saveAsTextFilter.Text + "|*.xml", DefaultExt = ".xml", AddExtension = true }; if (fileDialog.ShowDialog(this) == DialogResult.OK) { TranslationSerializer.Serialize(foreignTranslation, fileDialog.FileName); changesMade = false; } }