Parse() 공개 메소드

Parses a GNU MO file from the given stream and loads all available data.
http://www.gnu.org/software/gettext/manual/html_node/MO-Files.html
public Parse ( Stream stream ) : MoFile
stream Stream Stream that contain binary data in the MO file format
리턴 MoFile
예제 #1
0
 public void TestManualEncoding()
 {
     using (var stream = File.OpenRead(Path.Combine(LocalesDir, Path.Combine("ru_RU", Path.Combine("LC_MESSAGES", "Test_KOI8-R.mo")))))
     {
         var parser = new MoFileParser(Encoding.GetEncoding("KOI8-R"), false);
         var parsedFile = parser.Parse(stream);
         this._TestLoadedTranslation(parsedFile.Translations);
     }
 }
예제 #2
0
 public void TestParsing()
 {
     using (var stream = File.OpenRead(Path.Combine(LocalesDir, Path.Combine("ru_RU", Path.Combine("LC_MESSAGES", "Test.mo")))))
     {
         var parser = new MoFileParser();
         parser.Parse(stream);
         this._TestLoadedTranslation(parser.Translations);
     }
 }
예제 #3
0
        /// <summary>
        /// Load translations from given MO file stream using given encoding.
        /// </summary>
        /// <remarks>
        /// By default, parser will try to detect file encoding automatically with fallback to UTF-8 encoding.
        /// If you specify any encoding in this method, auto-detect will be turned off and given encoding will be used instead.
        /// </remarks>
        /// <param name="moStream">Stream that contain binary data in the MO file format</param>
        /// <param name="encoding">File encoding (auto detect by default)</param>
        public void Load(Stream moStream, Encoding encoding = null)
        {
            var parser = new MoFileParser();
            if (encoding != null)
            {
                parser.DetectEncoding = false;
                parser.Encoding = encoding;
            }

            parser.Parse(moStream);

            this.Translations = parser.Translations;
        }