예제 #1
0
 public override void Put(IEnumerable <LocalizedTextState> texts, TextMergeOptions options)
 {
     BeginUpdate();
     Texts.Clear();
     foreach (var text in texts.Select(x => x.Text))
     {
         Texts.Add(text);
     }
     OnTextsChanged();
 }
예제 #2
0
 public override void Put(IEnumerable<LocalizedTextState> texts, TextMergeOptions options)
 {
     BeginUpdate();
     Texts.Clear();
     foreach (var text in texts.Select(x => x.Text))
     {
         Texts.Add(text);
     }            
     OnTextsChanged();
 }
예제 #3
0
 public virtual void Merge(TextMergeOptions options)
 {
     Destination.Put(Diff(), options);
 }
예제 #4
0
 public override void Put(IEnumerable<LocalizedTextState> texts, TextMergeOptions options)
 {            
     throw new NotSupportedException("This text source does not support saving texts");
 }
예제 #5
0
        public override void Put(IEnumerable <LocalizedTextState> texts, TextMergeOptions options)
        {
            //TODO: Implement TextMergeOptions

            if (_readOnly)
            {
                throw new NotSupportedException("This text source does not support saving texts");
            }

            if (Document == null || Document.Root == null)
            {
                Document = new XDocument(new XElement("Localizations"));
            }

            var root = Document.Root;

            if (!string.IsNullOrEmpty(SingleLanguage))
            {
                texts = texts.Where(x => x.Text.Language == SingleLanguage);
                root.SetAttributeValue("Language", SingleLanguage);
            }

            string defaultDialect = (string)root.Attribute("PatternDialect");

            if (string.IsNullOrEmpty(defaultDialect))
            {
                defaultDialect = "Default";
            }


            root.Elements().Remove();
            foreach (var ns in texts.Fold((x) => x.Text, (x) => x))
            {
                var parent = root;
                if (!string.IsNullOrEmpty(ns.Key) && ns.Key != DefaultNamespace)
                {
                    parent = new XElement("Namespace", new XAttribute("Name", ns.Key));
                    root.Add(parent);
                }

                foreach (var key in ns.Value)
                {
                    var textElement = new XElement("Text");
                    textElement.Add(new XAttribute("Key", key.Key));

                    foreach (var state in key.Value.Values)
                    {
                        if ((state.Status & LocalizedTextStatus.Unused) == 0 || options == TextMergeOptions.KeepUnused)
                        {
                            var trans = state.Text;

                            var translationElement = string.IsNullOrEmpty(SingleLanguage) ? new XElement("Translation") : textElement;

                            translationElement.Add(new XAttribute("Language", trans.Language));
                            if (trans.PatternDialect != defaultDialect)
                            {
                                translationElement.Add(new XAttribute("PatternDialect", trans.PatternDialect));
                            }

                            if (trans.Source != null && !string.IsNullOrEmpty(trans.Source.Details))
                            {
                                translationElement.Add(new XAttribute("Source", trans.Source));
                            }

                            if (trans.Quality != TextQuality.Proper)
                            {
                                translationElement.Add(
                                    new XAttribute("Quality", Enum.GetName(typeof(TextQuality), trans.Quality)));
                            }

                            translationElement.Value = trans.Pattern;

                            if (textElement != translationElement)
                            {
                                textElement.Add(translationElement);
                            }
                        }
                    }

                    parent.Add(textElement);
                }
            }
            OnTextsChanged();
        }
예제 #6
0
 public virtual void Merge(TextMergeOptions options)
 {
     Destination.Put(Diff(), options);
 }
 public override void Put(IEnumerable <LocalizedTextState> texts, TextMergeOptions options)
 {
     throw new NotSupportedException("This text source does not support saving texts");
 }
예제 #8
0
 public abstract void Put(IEnumerable <LocalizedTextState> texts, TextMergeOptions options);