Beispiel #1
0
        public static void load_translation(emu_options m_options)
        {
            util.unload_translation();

            string name = m_options.language();

            if (name.empty())
            {
                return;
            }

            strreplace(ref name, " ", "_");
            strreplace(ref name, "(", "");
            strreplace(ref name, ")", "");
            emu_file file = new emu_file(m_options.language_path(), OPEN_FLAG_READ);

            if (file.open(name + PATH_SEPARATOR + "strings.mo"))
            {
                osd_printf_error("Error opening translation file {0}\n", name);
                return;
            }

            osd_printf_verbose("Loading translation file {0}\n", file.fullpath());
            util.load_translation(file.core_file_get());
        }
Beispiel #2
0
        public static void load_translation(emu_options m_options)
        {
            g_translation.Clear();
            emu_file file = new emu_file(m_options.language_path(), global_object.OPEN_FLAG_READ);
            var      name = m_options.language();

            name = name.Replace(" ", "_");
            name = name.Replace("(", "");
            name = name.Replace(")", "");
            if (file.open(name, global_object.PATH_SEPARATOR + "strings.mo") == osd_file.error.NONE)
            {
                uint64_t  size   = file.size();
                RawBuffer buffer = new RawBuffer(4 * (int)size / 4 + 1); //uint32_t *buffer = global_alloc_array(uint32_t, size / 4 + 1);
                file.read(new ListBytesPointer(buffer), (UInt32)size);
                file.close();

                if (buffer.get_uint32(0) != MO_MAGIC && buffer.get_uint32(0) != MO_MAGIC_REVERSED)
                {
                    buffer = null;  //global_free_array(buffer);
                    return;
                }
                if (buffer.get_uint32(0) == MO_MAGIC_REVERSED)
                {
                    for (var i = 0; i < ((int)size / 4) + 1; ++i)
                    {
                        buffer.set_uint32(i, endianchange(buffer[i]));
                    }
                }

                uint32_t number_of_strings        = buffer.get_uint32(2);
                uint32_t original_table_offset    = buffer.get_uint32(3) >> 2;
                uint32_t translation_table_offset = buffer.get_uint32(4) >> 2;

                RawBuffer data = buffer;  //const char *data = reinterpret_cast<const char*>(buffer);

                for (var i = 1; i < number_of_strings; ++i)
                {
                    string original    = "TODO original";    //(const char *)data + buffer[original_table_offset + 2 * i + 1];
                    string translation = "TODO translation"; //(const char *)data + buffer[translation_table_offset + 2 * i + 1];
                    g_translation.emplace(original, translation);
                }

                buffer = null;  //global_free_array(buffer);
            }
        }