Esempio n. 1
0
        private void CompileTranslation(MetadataCsvReader meta, TextReader translation, TextReader source, TextWriter dest)
        {
            var src          = new CharCountingReader(source);
            var substitution = new SpanPairReader(translation);

            _config = DotConfig.GetConfiguration(Workspace.SourcePath);

            foreach (TextSpan span in meta.GetSpans())
            {
                int preserveSize = (int)span.Offset - src.Position;
                if (src.TextCopyTo(dest, preserveSize) != preserveSize)
                {
                    return;
                }

                string translated = substitution.ReadCorrespondingSpan(span);
                translated = ApplyPostProcess(span, src, translated);
                if (translated == null)
                {
                    continue;
                }
                dest.Write(translated);
            }
            _ = src.TextCopyTo(dest, int.MaxValue);
            // TODO: warn mismatch of translation having more line
        }
Esempio n. 2
0
        private string ApplyPostProcess(TextSpan span, CharCountingReader src, string translation)
        {
            string original = src.ReadString((int)span.Length);

            return(_config !.PostReplace(span.Title ?? "", original, translation));
        }