public static LocalizedString Merge(LocalizedString a, LocalizedString b) { if (!a.UntranslatedEquals(b)) { throw new Exception("Cannot merge two strings with different untranslated values"); }/* * FIXME: don't enforce gender merging because gender isn't properly handled * anywhere else. Need to figure out how to generate PO strings that differentiate * gender... until then, don't enforce this. * else if (a.Gender != b.Gender) { * throw new Exception ("Cannot merge two strings with different genders"); * }*/ var merged = new LocalizedString { UntranslatedSingularValue = a.UntranslatedSingularValue, UntranslatedPluralValue = a.UntranslatedPluralValue, Gender = a.Gender, StringFormatHint = a.StringFormatHint ?? b.StringFormatHint, DeveloperComments = Join(a.DeveloperComments, b.DeveloperComments), TranslatorComments = Join(a.TranslatorComments, b.TranslatorComments) }; var a_translated = new List <string> (a.TranslatedValues ?? new string [0]); var b_translated = new List <string> (b.TranslatedValues ?? new string [0]); if (b_translated.Count >= a_translated.Count) { a_translated = b_translated; } if (a_translated.Count > 0) { merged.TranslatedValues = a_translated.ToArray(); } var a_references = new List <string> (a.References ?? new string [0]); var b_references = new List <string> (b.References ?? new string [0]); foreach (var reference in b_references) { if (!a_references.Contains(reference)) { a_references.Add(reference); } } if (a_references.Count > 0) { merged.References = a_references.ToArray(); } return(merged); }
public static LocalizedString Merge(LocalizedString a, LocalizedString b) { if (!a.UntranslatedEquals(b)) { throw new Exception("Cannot merge two strings with different untranslated values"); } var merged = new LocalizedString { Context = a.Context, UntranslatedSingularValue = a.UntranslatedSingularValue, UntranslatedPluralValue = a.UntranslatedPluralValue, Gender = a.Gender, StringFormatHint = a.StringFormatHint ?? b.StringFormatHint, DeveloperComments = Join(a.DeveloperComments, b.DeveloperComments), TranslatorComments = Join(a.TranslatorComments, b.TranslatorComments) }; var a_translated = new List <string> (a.TranslatedValues ?? new string [0]); var b_translated = new List <string> (b.TranslatedValues ?? new string [0]); if (b_translated.Count >= a_translated.Count) { a_translated = b_translated; } if (a_translated.Count > 0) { merged.TranslatedValues = a_translated.ToArray(); } var a_references = new List <string> (a.References ?? new string [0]); var b_references = new List <string> (b.References ?? new string [0]); foreach (var reference in b_references) { if (!a_references.Contains(reference)) { a_references.Add(reference); } } if (a_references.Count > 0) { merged.References = a_references.ToArray(); } return(merged); }
public static LocalizedString Merge(LocalizedString a, LocalizedString b) { if (!a.UntranslatedEquals (b)) { throw new Exception ("Cannot merge two strings with different untranslated values"); } var merged = new LocalizedString { Context = a.Context, UntranslatedSingularValue = a.UntranslatedSingularValue, UntranslatedPluralValue = a.UntranslatedPluralValue, Gender = a.Gender, StringFormatHint = a.StringFormatHint ?? b.StringFormatHint, DeveloperComments = Join (a.DeveloperComments, b.DeveloperComments), TranslatorComments = Join (a.TranslatorComments, b.TranslatorComments) }; var a_translated = new List<string> (a.TranslatedValues ?? new string [0]); var b_translated = new List<string> (b.TranslatedValues ?? new string [0]); if (b_translated.Count >= a_translated.Count) { a_translated = b_translated; } if (a_translated.Count > 0) { merged.TranslatedValues = a_translated.ToArray (); } var a_references = new List<string> (a.References ?? new string [0]); var b_references = new List<string> (b.References ?? new string [0]); foreach (var reference in b_references) { if (!a_references.Contains (reference)) { a_references.Add (reference); } } if (a_references.Count > 0) { merged.References = a_references.ToArray (); } return merged; }
public static LocalizedString Merge(LocalizedString a, LocalizedString b) { if (!a.UntranslatedEquals (b)) { throw new Exception ("Cannot merge two strings with different untranslated values"); }/* FIXME: don't enforce gender merging because gender isn't properly handled anywhere else. Need to figure out how to generate PO strings that differentiate gender... until then, don't enforce this. else if (a.Gender != b.Gender) { throw new Exception ("Cannot merge two strings with different genders"); }*/ var merged = new LocalizedString { UntranslatedSingularValue = a.UntranslatedSingularValue, UntranslatedPluralValue = a.UntranslatedPluralValue, Gender = a.Gender, StringFormatHint = a.StringFormatHint ?? b.StringFormatHint, DeveloperComments = Join (a.DeveloperComments, b.DeveloperComments), TranslatorComments = Join (a.TranslatorComments, b.TranslatorComments) }; var a_translated = new List<string> (a.TranslatedValues ?? new string [0]); var b_translated = new List<string> (b.TranslatedValues ?? new string [0]); if (b_translated.Count >= a_translated.Count) { a_translated = b_translated; } if (a_translated.Count > 0) { merged.TranslatedValues = a_translated.ToArray (); } var a_references = new List<string> (a.References ?? new string [0]); var b_references = new List<string> (b.References ?? new string [0]); foreach (var reference in b_references) { if (!a_references.Contains (reference)) { a_references.Add (reference); } } if (a_references.Count > 0) { merged.References = a_references.ToArray (); } return merged; }