Bloom.Book.BookData.PossiblyCopyFromAnotherLanguage C# (CSharp) Method

PossiblyCopyFromAnotherLanguage() private method

In some cases, we're better off copying from another national language than leaving the field empty.
This is a tough decision. Without this, if we have, say, an English Contributors list but English isn't the N1 (L2), then the book won't show it at all. An ideal solution would just order them and then "display the first non-empty one", but that would require some java script... not something could be readily done in CSS, far as I can think. For now, I *think* this won't do any harm, and if it does, it's adding data, not losing it. Users had complained about "losing" the contributor data before.
private PossiblyCopyFromAnotherLanguage ( XmlElement element, string languageCodeOfTargetField, DataSet data, string key ) : string
element System.Xml.XmlElement
languageCodeOfTargetField string
data DataSet
key string
return string
        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;
        }