mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
Added multi-language support for MAME [Miodrag Milanovic]
Added sample language to show display in cyrillic use mame -lang "Serbian (Cyrillic)"
This commit is contained in:
parent
d3b7026eca
commit
0bc4173bd3
@ -112,15 +112,15 @@ msgstr ""
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:53
|
||||
msgid "Input (general)"
|
||||
msgstr ""
|
||||
msgstr "Улази (генерално)"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:55
|
||||
msgid "Input (this Machine)"
|
||||
msgstr ""
|
||||
msgstr "Улази (ова машина)"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:59
|
||||
msgid "Analog Controls"
|
||||
msgstr ""
|
||||
msgstr "Аналогне контроле"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:61
|
||||
msgid "Dip Switches"
|
||||
@ -128,7 +128,7 @@ msgstr ""
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:64
|
||||
msgid "Machine Configuration"
|
||||
msgstr ""
|
||||
msgstr "Конфигурација"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:68
|
||||
msgid "Bookkeeping Info"
|
||||
@ -136,51 +136,51 @@ msgstr ""
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:71
|
||||
msgid "Machine Information"
|
||||
msgstr ""
|
||||
msgstr "Информације о машини"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:77
|
||||
msgid "Image Information"
|
||||
msgstr ""
|
||||
msgstr "Информације о датотеци"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:80
|
||||
msgid "File Manager"
|
||||
msgstr ""
|
||||
msgstr "Менаџер датотека"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:85
|
||||
msgid "Tape Control"
|
||||
msgstr ""
|
||||
msgstr "Контрола касете"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:90
|
||||
msgid "Pseudo terminals"
|
||||
msgstr ""
|
||||
msgstr "Псеудо терминал"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:93
|
||||
msgid "Bios Selection"
|
||||
msgstr ""
|
||||
msgstr "Селекција биоса"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:99
|
||||
msgid "Slot Devices"
|
||||
msgstr ""
|
||||
msgstr "Слот уређаји"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:106
|
||||
msgid "Barcode Reader"
|
||||
msgstr ""
|
||||
msgstr "Читач бар кода"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:113
|
||||
msgid "Network Devices"
|
||||
msgstr ""
|
||||
msgstr "Мрежни уређаји"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:118
|
||||
msgid "Keyboard Mode"
|
||||
msgstr ""
|
||||
msgstr "Мод тастатуре"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:121
|
||||
msgid "Slider Controls"
|
||||
msgstr ""
|
||||
msgstr "Клизачи"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:124
|
||||
msgid "Video Options"
|
||||
msgstr ""
|
||||
msgstr "Видео операције"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:128
|
||||
msgid "Crosshair Options"
|
||||
@ -188,7 +188,7 @@ msgstr ""
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:132
|
||||
msgid "Cheat"
|
||||
msgstr ""
|
||||
msgstr "Варања"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:136
|
||||
msgid "External DAT View"
|
||||
@ -196,12 +196,12 @@ msgstr ""
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:142
|
||||
msgid "Add To Favorites"
|
||||
msgstr ""
|
||||
msgstr "Додај у омиљене"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:144
|
||||
msgid "Remove From Favorites"
|
||||
msgstr ""
|
||||
msgstr "Уклони из омиљених"
|
||||
|
||||
#: src/emu/ui/mainmenu.cpp:151
|
||||
msgid "Select New Machine"
|
||||
msgstr ""
|
||||
msgstr "Селектуј нову машину"
|
||||
|
2
makefile
2
makefile
@ -1379,7 +1379,7 @@ shaders:
|
||||
|
||||
translation:
|
||||
$(SILENT) echo Generating mame.pot
|
||||
$(SILENT) find src/emu/ui -iname "*.cpp" | xargs xgettext --from-code=UTF-8 -k_ -o mame.pot
|
||||
$(SILENT) find src -iname "*.cpp" | xargs xgettext --from-code=UTF-8 -k_ -o mame.pot
|
||||
$(SILENT) echo Afrikaans
|
||||
$(SILENT) msgmerge -U "language/Afrikaans/strings.po" mame.pot
|
||||
$(SILENT) echo Albanian
|
||||
|
@ -89,6 +89,68 @@ cli_frontend::~cli_frontend()
|
||||
m_options.remove_device_options();
|
||||
}
|
||||
|
||||
const UINT32 MO_MAGIC = 0x950412de;
|
||||
const UINT32 MO_MAGIC_REVERSED = 0xde120495;
|
||||
|
||||
inline UINT32 endianchange(UINT32 value) {
|
||||
UINT32 b0 = (value >> 0) & 0xff;
|
||||
UINT32 b1 = (value >> 8) & 0xff;
|
||||
UINT32 b2 = (value >> 16) & 0xff;
|
||||
UINT32 b3 = (value >> 24) & 0xff;
|
||||
|
||||
return (b0 << 24) | (b1 << 16) |(b2 << 8) | b3;
|
||||
}
|
||||
|
||||
static std::unordered_map<std::string, std::string> g_translation;
|
||||
|
||||
const char *lang_translate(const char *word)
|
||||
{
|
||||
if (g_translation.find(word) == g_translation.end())
|
||||
{
|
||||
return word;
|
||||
}
|
||||
return g_translation[word].c_str();
|
||||
}
|
||||
|
||||
void cli_frontend::load_translation()
|
||||
{
|
||||
g_translation.empty();
|
||||
emu_file file(m_options.language_path(), OPEN_FLAG_READ);
|
||||
if (file.open(m_options.language(), PATH_SEPARATOR "strings.mo") == FILERR_NONE)
|
||||
{
|
||||
UINT64 size = file.size();
|
||||
UINT32 *buffer = global_alloc_array(UINT32,size / 4 + 1);
|
||||
file.read(buffer, size);
|
||||
file.close();
|
||||
|
||||
if (buffer[0] != MO_MAGIC && buffer[0] != MO_MAGIC_REVERSED)
|
||||
{
|
||||
global_free_array(buffer);
|
||||
return;
|
||||
}
|
||||
if (buffer[0] == MO_MAGIC_REVERSED)
|
||||
{
|
||||
for (auto i = 0; i < (size / 4)+1; ++i)
|
||||
{
|
||||
buffer[i] = endianchange(buffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
UINT32 number_of_strings = buffer[2];
|
||||
UINT32 original_table_offset = buffer[3] >> 2;
|
||||
UINT32 translation_table_offset = buffer[4] >> 2;
|
||||
|
||||
const char *data = reinterpret_cast<const char*>(buffer);
|
||||
|
||||
for (auto i = 1; i < number_of_strings; ++i)
|
||||
{
|
||||
std::string original = (const char *)data + buffer[original_table_offset + 2 * i + 1];
|
||||
std::string translation= (const char *)data + buffer[translation_table_offset + 2 * i + 1];
|
||||
g_translation.insert(std::pair<std::string, std::string>(original, translation));
|
||||
}
|
||||
global_free_array(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// execute - execute a game via the standard
|
||||
@ -109,6 +171,8 @@ int cli_frontend::execute(int argc, char **argv)
|
||||
|
||||
m_options.parse_standard_inis(option_errors);
|
||||
|
||||
load_translation();
|
||||
|
||||
manager->start_luaengine();
|
||||
|
||||
if (*(m_options.software_name()) != 0)
|
||||
|
@ -32,6 +32,8 @@ public:
|
||||
cli_frontend(cli_options &options, osd_interface &osd);
|
||||
~cli_frontend();
|
||||
|
||||
void load_translation();
|
||||
|
||||
// execute based on the incoming argc/argv
|
||||
int execute(int argc, char **argv);
|
||||
|
||||
|
@ -44,6 +44,7 @@ const options_entry emu_options::s_option_entries[] =
|
||||
{ OPTION_CHEATPATH, "cheat", OPTION_STRING, "path to cheat files" },
|
||||
{ OPTION_CROSSHAIRPATH, "crosshair", OPTION_STRING, "path to crosshair files" },
|
||||
{ OPTION_PLUGINSPATH, "plugins", OPTION_STRING, "path to plugin files" },
|
||||
{ OPTION_LANGUAGEPATH, "language", OPTION_STRING, "path to language files" },
|
||||
|
||||
// output directory options
|
||||
{ nullptr, nullptr, OPTION_HEADER, "CORE OUTPUT DIRECTORY OPTIONS" },
|
||||
@ -188,6 +189,7 @@ const options_entry emu_options::s_option_entries[] =
|
||||
{ OPTION_AUTOBOOT_DELAY, "2", OPTION_INTEGER, "timer delay in sec to trigger command execution on autoboot" },
|
||||
{ OPTION_AUTOBOOT_SCRIPT ";script", nullptr, OPTION_STRING, "lua script to execute after machine boot" },
|
||||
{ OPTION_CONSOLE, "0", OPTION_BOOLEAN, "enable emulator LUA console" },
|
||||
{ OPTION_LANGUAGE ";lang", "English", OPTION_STRING, "display language" },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
|
@ -57,6 +57,7 @@ enum
|
||||
#define OPTION_CHEATPATH "cheatpath"
|
||||
#define OPTION_CROSSHAIRPATH "crosshairpath"
|
||||
#define OPTION_PLUGINSPATH "pluginspath"
|
||||
#define OPTION_LANGUAGEPATH "languagepath"
|
||||
|
||||
// core directory options
|
||||
#define OPTION_CFG_DIRECTORY "cfg_directory"
|
||||
@ -190,6 +191,8 @@ enum
|
||||
|
||||
#define OPTION_CONSOLE "console"
|
||||
|
||||
#define OPTION_LANGUAGE "language"
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
@ -233,6 +236,7 @@ public:
|
||||
const char *cheat_path() const { return value(OPTION_CHEATPATH); }
|
||||
const char *crosshair_path() const { return value(OPTION_CROSSHAIRPATH); }
|
||||
const char *plugins_path() const { return value(OPTION_PLUGINSPATH); }
|
||||
const char *language_path() const { return value(OPTION_LANGUAGEPATH); }
|
||||
|
||||
// core directory options
|
||||
const char *cfg_directory() const { return value(OPTION_CFG_DIRECTORY); }
|
||||
@ -363,6 +367,8 @@ public:
|
||||
const char *autoboot_script() const { return value(OPTION_AUTOBOOT_SCRIPT); }
|
||||
|
||||
bool console() const { return bool_value(OPTION_CONSOLE); }
|
||||
|
||||
const char *language() const { return value(OPTION_LANGUAGE); }
|
||||
|
||||
// FIXME: Couriersud: This should be in image_device_exit
|
||||
void remove_device_options();
|
||||
|
@ -100,6 +100,14 @@ private:
|
||||
static machine_manager* m_manager;
|
||||
};
|
||||
|
||||
//**************************************************************************
|
||||
// LOCALIZATION SUPPORT
|
||||
//**************************************************************************
|
||||
|
||||
#define _(param) lang_translate(param)
|
||||
|
||||
extern const char *lang_translate(const char *word);
|
||||
|
||||
//**************************************************************************
|
||||
// GLOBAL VARIABLES
|
||||
//**************************************************************************
|
||||
|
@ -85,10 +85,6 @@ enum
|
||||
|
||||
#define SLIDER_NOCHANGE 0x12345678
|
||||
|
||||
/***************************************************************************
|
||||
FOR FUTURE LOCALIZATION
|
||||
***************************************************************************/
|
||||
#define _(param) param
|
||||
|
||||
/***************************************************************************
|
||||
TYPE DEFINITIONS
|
||||
|
Loading…
Reference in New Issue
Block a user