Translate() public method

Attempts to translate the specified message.
public Translate ( Message message ) : Message
message Message The message to translate.
return Message
コード例 #1
0
        private void Fixup(string srcPath, string dstPath)
        {
            Message message;
            var stats = new Statistics();
            var classifier = new MessageClassifier();
            var translator = new LiveMessageTranslator();

            using(var input = File.OpenRead(srcPath))
            using(var reader = new DecoratedObjectReader(input))
            using(var output = File.Create(dstPath))
            using(var writer = new DecoratedObjectWriter(output))
            {
                while(true)
                {
                    if((message = reader.Read<Message>()) == null)
                    {
                        break;
                    }
                    ++stats.Read;
                    if(classifier.IsTranslated(message))
                    {
                        ++stats.OrgTranslated;
                        continue;
                    }
                    writer.Write(message);
                    ++stats.Written;
                    if((message = translator.Translate(message)) != null)
                    {
                        if(message is CompositeMessage)
                        {
                            foreach(var component in ((CompositeMessage)message).Messages)
                            {
                                writer.Write(component);
                                ++stats.Written;
                                ++stats.NewTranslated;
                            }
                        }
                        else
                        {
                            writer.Write(message);
                            ++stats.Written;
                            ++stats.NewTranslated;
                        }
                    }
                }
                writer.Write(null);
            }

            stats.Print();
        }