private string PossiblyCopyFromAnotherLanguage(XmlElement element, string languageCodeOfTargetField, DataSet data, string key)
{
string classes = element.GetAttribute("class");
if (!string.IsNullOrEmpty(classes))
{
// if this field is normally read-only, make it readable so they can do any translation that might be needed
element.SetAttribute("class", classes.Replace("bloom-readOnlyInTranslationMode", ""));
}
if (!classes.Contains("bloom-copyFromOtherLanguageIfNecessary"))
{
return "";
}
LanguageForm formToCopyFromSinceOursIsMissing = null;
string s = "";
if ((languageCodeOfTargetField == _collectionSettings.Language2Iso639Code || //is it a national language?
languageCodeOfTargetField == _collectionSettings.Language3Iso639Code) ||
//this one is a kludge as we clearly have this case of a vernacular field that people have used
//to hold stuff that should be copied to every shell. So we can either remove the restriction of the
//first two clauses in this if statement, or add another bloom-___ class in order to make execptions.
//Today, I'm not seing the issue clearly enough, so I'm just going to path this one exisint hole.
classes.Contains("smallCoverCredits"))
{
formToCopyFromSinceOursIsMissing =
data.TextVariables[key].TextAlternatives.GetBestAlternative(new[] {languageCodeOfTargetField, "*", "en", "fr", "es", "pt"});
if (formToCopyFromSinceOursIsMissing != null)
s = formToCopyFromSinceOursIsMissing.Form;
if (string.IsNullOrEmpty(s))
{
//OK, well even on a non-global language is better than none
//s = data.TextVariables[key].TextAlternatives.GetFirstAlternative();
formToCopyFromSinceOursIsMissing = GetFirstAlternativeForm(data.TextVariables[key].TextAlternatives);
if (formToCopyFromSinceOursIsMissing != null)
s = formToCopyFromSinceOursIsMissing.Form;
}
}
/* this was a fine idea, execpt that if the user then edits it, well, it's not borrowed anymore but we'll still have this sitting there misleading us
//record our dubious deed for posterity
if (formToCopyFromSinceOursIsMissing != null)
{
node.SetAttribute("bloom-languageBloomHadToCopyFrom",
formToCopyFromSinceOursIsMissing.WritingSystemId);
}
*/
return s;
}