    # File lib/gettext/runtime/mofile.rb, line 87
        def load_from_stream(io)
          magic = io.read(4)
          case magic
          when MAGIC_BIG_ENDIAN
            @little_endian = false
          when MAGIC_LITTLE_ENDIAN
            @little_endian = true
          else
            raise InvalidFormat.new(sprintf("Unknown signature %s", magic.dump))
          end

          endian_type6 = @little_endian ? 'V6' : 'N6'
          endian_type_astr = @little_endian ? 'V*' : 'N*'

          header = HeaderRev1.new(magic, *(io.read(4 * 6).unpack(endian_type6)))

          if header.revision == 1
            # FIXME: It doesn't support sysdep correctly.
            header.n_sysdep_segments = io.read(4).unpack(endian_type6)
            header.sysdep_segments_offset = io.read(4).unpack(endian_type6)
            header.n_sysdep_strings = io.read(4).unpack(endian_type6)
            header.orig_sysdep_tab_offset = io.read(4).unpack(endian_type6)
            header.trans_sysdep_tab_offset = io.read(4).unpack(endian_type6)
          elsif header.revision > 1
            raise InvalidFormat.new(sprintf("file format revision %d isn't supported", header.revision))
          end
          io.pos = header.orig_table_offset
          orig_table_data = io.read((4 * 2) * header.nstrings).unpack(endian_type_astr)

          io.pos = header.translated_table_offset
          trans_table_data = io.read((4 * 2) * header.nstrings).unpack(endian_type_astr)

          original_strings = Array.new(header.nstrings)
          for i in 0...header.nstrings
            io.pos = orig_table_data[i * 2 + 1]
            original_strings[i] = io.read(orig_table_data[i * 2 + 0])
          end

          clear
          for i in 0...header.nstrings
            io.pos = trans_table_data[i * 2 + 1]
            str = io.read(trans_table_data[i * 2 + 0])

            if (! original_strings[i]) || original_strings[i] == ""
              if str
                @charset = nil
                @nplurals = nil
                @plural = nil
                str.each_line{|line|
                  if /^Content-Type:/i =~ line and /charset=((?:\w|-)+)/i =~ line
                    @charset = $1
                  elsif /^Plural-Forms:\s*nplurals\s*\=\s*(\d*);\s*plural\s*\=\s*([^;]*)\n?/ =~ line
                    @nplurals = $1
                    @plural = $2
                  end
                  break if @charset and @nplurals
                }
                @nplurals = "1" unless @nplurals
                @plural = "0" unless @plural
              end
            else
              if @output_charset
                begin
                  str = Iconv.conv(@output_charset, @charset, str) if @charset
                rescue Iconv::Failure
                  if $DEBUG
                    warn "@charset = ", @charset
                    warn"@output_charset = ", @output_charset
                    warn "msgid = ", original_strings[i]
                    warn "msgstr = ", str
                  end
                end
              end
            end
            self[original_strings[i]] = str.freeze
          end
          self
        end