I HATE GLOBAL CONFIGS I HATE GLOBAL CONFIGS I HATE
@tildearrow instead of this nonsense you could have just made a language menu in the interface settings
This commit is contained in:
parent
8e115220a3
commit
c9482ba86c
|
@ -182,30 +182,6 @@ if (WIN32)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WITH_LOCALE)
|
|
||||||
if (USE_MOMO)
|
|
||||||
add_library(momo STATIC src/momo/momo.c)
|
|
||||||
list(APPEND DEPENDENCIES_DEFINES HAVE_LOCALE)
|
|
||||||
list(APPEND DEPENDENCIES_DEFINES HAVE_MOMO)
|
|
||||||
list(APPEND DEPENDENCIES_INCLUDE_DIRS src/momo)
|
|
||||||
list(APPEND DEPENDENCIES_LIBRARIES momo)
|
|
||||||
message(STATUS "Using libintl (Momo)")
|
|
||||||
else()
|
|
||||||
if ("${CMAKE_VERSION}" VERSION_LESS "3.2")
|
|
||||||
message(FATAL_ERROR "CMake 3.2 or later required for locale support.")
|
|
||||||
else()
|
|
||||||
include(FindIntl)
|
|
||||||
if (NOT Intl_FOUND)
|
|
||||||
message(FATAL_ERROR "Could not find libintl! Try enabling USE_MOMO.")
|
|
||||||
endif()
|
|
||||||
list(APPEND DEPENDENCIES_DEFINES HAVE_LOCALE)
|
|
||||||
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${Intl_INCLUDE_DIRS})
|
|
||||||
list(APPEND DEPENDENCIES_LIBRARIES ${Intl_LIBRARIES})
|
|
||||||
message(STATUS "Using libintl (system)")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (SYSTEM_FFTW)
|
if (SYSTEM_FFTW)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(FFTW REQUIRED fftw3>=3.3)
|
pkg_check_modules(FFTW REQUIRED fftw3>=3.3)
|
||||||
|
@ -1062,6 +1038,29 @@ if (NOT WIN32)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (WITH_LOCALE)
|
||||||
|
if (USE_MOMO)
|
||||||
|
list(APPEND ENGINE_SOURCES src/momo/momo.c)
|
||||||
|
list(APPEND DEPENDENCIES_DEFINES HAVE_LOCALE)
|
||||||
|
list(APPEND DEPENDENCIES_DEFINES HAVE_MOMO)
|
||||||
|
list(APPEND DEPENDENCIES_INCLUDE_DIRS src/momo)
|
||||||
|
message(STATUS "Using libintl (Momo)")
|
||||||
|
else()
|
||||||
|
if ("${CMAKE_VERSION}" VERSION_LESS "3.2")
|
||||||
|
message(FATAL_ERROR "CMake 3.2 or later required for locale support.")
|
||||||
|
else()
|
||||||
|
include(FindIntl)
|
||||||
|
if (NOT Intl_FOUND)
|
||||||
|
message(FATAL_ERROR "Could not find libintl! Try enabling USE_MOMO.")
|
||||||
|
endif()
|
||||||
|
list(APPEND DEPENDENCIES_DEFINES HAVE_LOCALE)
|
||||||
|
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${Intl_INCLUDE_DIRS})
|
||||||
|
list(APPEND DEPENDENCIES_LIBRARIES ${Intl_LIBRARIES})
|
||||||
|
message(STATUS "Using libintl (system)")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
set(USED_SOURCES ${ENGINE_SOURCES} ${AUDIO_SOURCES} ${CLI_SOURCES} src/main.cpp)
|
set(USED_SOURCES ${ENGINE_SOURCES} ${AUDIO_SOURCES} ${CLI_SOURCES} src/main.cpp)
|
||||||
|
|
||||||
if (USE_BACKWARD)
|
if (USE_BACKWARD)
|
||||||
|
|
|
@ -3956,15 +3956,24 @@ bool DivEngine::deinitAudioBackend(bool dueToSwitchMaster) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DivEngine::preInit(bool noSafeMode) {
|
bool DivEngine::prePreInit() {
|
||||||
bool wantSafe=false;
|
|
||||||
// register systems
|
|
||||||
if (!systemsRegistered) registerSystems();
|
|
||||||
|
|
||||||
// init config
|
// init config
|
||||||
initConfDir();
|
initConfDir();
|
||||||
logD("config path: %s",configPath.c_str());
|
logD("config path: %s",configPath.c_str());
|
||||||
|
|
||||||
|
configLoaded=true;
|
||||||
|
return loadConf();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DivEngine::preInit(bool noSafeMode) {
|
||||||
|
bool wantSafe=false;
|
||||||
|
if (!configLoaded) prePreInit();
|
||||||
|
|
||||||
|
logI("Furnace version " DIV_VERSION ".");
|
||||||
|
|
||||||
|
// register systems
|
||||||
|
if (!systemsRegistered) registerSystems();
|
||||||
|
|
||||||
// TODO: re-enable with a better approach
|
// TODO: re-enable with a better approach
|
||||||
// see issue #1581
|
// see issue #1581
|
||||||
/*
|
/*
|
||||||
|
@ -3979,10 +3988,6 @@ bool DivEngine::preInit(bool noSafeMode) {
|
||||||
String logPath=configPath+DIR_SEPARATOR_STR+"furnace.log";
|
String logPath=configPath+DIR_SEPARATOR_STR+"furnace.log";
|
||||||
startLogFile(logPath.c_str());
|
startLogFile(logPath.c_str());
|
||||||
|
|
||||||
logI("Furnace version " DIV_VERSION ".");
|
|
||||||
|
|
||||||
loadConf();
|
|
||||||
|
|
||||||
if (!conf.has("opn1Core")) {
|
if (!conf.has("opn1Core")) {
|
||||||
if (conf.has("opnCore")) {
|
if (conf.has("opnCore")) {
|
||||||
conf.set("opn1Core",conf.getString("opnCore",""));
|
conf.set("opn1Core",conf.getString("opnCore",""));
|
||||||
|
|
|
@ -430,6 +430,7 @@ class DivEngine {
|
||||||
String exportPath;
|
String exportPath;
|
||||||
std::thread* exportThread;
|
std::thread* exportThread;
|
||||||
int chans;
|
int chans;
|
||||||
|
bool configLoaded;
|
||||||
bool active;
|
bool active;
|
||||||
bool lowQuality;
|
bool lowQuality;
|
||||||
bool dcHiPass;
|
bool dcHiPass;
|
||||||
|
@ -1295,6 +1296,9 @@ class DivEngine {
|
||||||
// quit dispatch
|
// quit dispatch
|
||||||
void quitDispatch();
|
void quitDispatch();
|
||||||
|
|
||||||
|
// pre-pre-initialize the engine.
|
||||||
|
bool prePreInit();
|
||||||
|
|
||||||
// pre-initialize the engine. returns whether Furnace should run in safe mode.
|
// pre-initialize the engine. returns whether Furnace should run in safe mode.
|
||||||
bool preInit(bool noSafeMode=true);
|
bool preInit(bool noSafeMode=true);
|
||||||
|
|
||||||
|
@ -1315,6 +1319,7 @@ class DivEngine {
|
||||||
output(NULL),
|
output(NULL),
|
||||||
exportThread(NULL),
|
exportThread(NULL),
|
||||||
chans(0),
|
chans(0),
|
||||||
|
configLoaded(false),
|
||||||
active(false),
|
active(false),
|
||||||
lowQuality(false),
|
lowQuality(false),
|
||||||
dcHiPass(true),
|
dcHiPass(true),
|
||||||
|
|
|
@ -1956,6 +1956,7 @@ class FurnaceGUI {
|
||||||
String emptyLabel2;
|
String emptyLabel2;
|
||||||
String sdlAudioDriver;
|
String sdlAudioDriver;
|
||||||
String defaultAuthorName;
|
String defaultAuthorName;
|
||||||
|
String locale;
|
||||||
DivConfig initialSys;
|
DivConfig initialSys;
|
||||||
|
|
||||||
Settings():
|
Settings():
|
||||||
|
@ -2210,7 +2211,8 @@ class FurnaceGUI {
|
||||||
emptyLabel("..."),
|
emptyLabel("..."),
|
||||||
emptyLabel2(".."),
|
emptyLabel2(".."),
|
||||||
sdlAudioDriver(""),
|
sdlAudioDriver(""),
|
||||||
defaultAuthorName("") {}
|
defaultAuthorName(""),
|
||||||
|
locale("") {}
|
||||||
} settings;
|
} settings;
|
||||||
|
|
||||||
struct Tutorial {
|
struct Tutorial {
|
||||||
|
|
|
@ -68,6 +68,27 @@
|
||||||
#define SYS_FILE_DIALOG_DEFAULT 1
|
#define SYS_FILE_DIALOG_DEFAULT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const char* locales[][2]={
|
||||||
|
{"<System>", ""},
|
||||||
|
{"English", "en_US"},
|
||||||
|
{"Deutsch", "de_DE"},
|
||||||
|
{"Español", "es_ES"},
|
||||||
|
{"Suomi", "fi_FI"},
|
||||||
|
{"Français", "fr_FR"},
|
||||||
|
{"Հայերեն", "hy_AM"},
|
||||||
|
{"한국어", "ko_KR"},
|
||||||
|
{"Nederlands", "nl_NL"},
|
||||||
|
{"Polski", "pl_PL"},
|
||||||
|
{"Português (Brasil)", "pt_BR"},
|
||||||
|
{"Русский", "ru_RU"},
|
||||||
|
{"Slovenčina", "sk_SK"},
|
||||||
|
{"Svenska", "sv_SE"},
|
||||||
|
{"ไทย", "th_TH"},
|
||||||
|
{"Türkçe", "tr_TR"},
|
||||||
|
{"Українська", "uk_UA"},
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
const char* fontBackends[]={
|
const char* fontBackends[]={
|
||||||
"stb_truetype",
|
"stb_truetype",
|
||||||
"FreeType"
|
"FreeType"
|
||||||
|
@ -549,6 +570,30 @@ void FurnaceGUI::drawSettings() {
|
||||||
CONFIG_SECTION(_("General")) {
|
CONFIG_SECTION(_("General")) {
|
||||||
// SUBSECTION PROGRAM
|
// SUBSECTION PROGRAM
|
||||||
CONFIG_SUBSECTION(_("Program"));
|
CONFIG_SUBSECTION(_("Program"));
|
||||||
|
|
||||||
|
String curLocale=settings.locale;
|
||||||
|
if (curLocale=="") {
|
||||||
|
curLocale="<System>";
|
||||||
|
} else {
|
||||||
|
for (int i=1; locales[i][0]; i++) {
|
||||||
|
if (strcmp(curLocale.c_str(),locales[i][1])==0) {
|
||||||
|
curLocale=locales[i][0];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ImGui::BeginCombo(_("Language"),curLocale.c_str())) {
|
||||||
|
for (int i=0; locales[i][0]; i++) {
|
||||||
|
if (ImGui::Selectable(locales[i][0],strcmp(settings.locale.c_str(),locales[i][1])==0)) {
|
||||||
|
settings.locale=locales[i][1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndCombo();
|
||||||
|
}
|
||||||
|
if (ImGui::IsItemHovered()) {
|
||||||
|
ImGui::SetTooltip(_("you may need to restart Furnace for this setting to take effect."));
|
||||||
|
}
|
||||||
|
|
||||||
String curRenderBackend=settings.renderBackend.empty()?GUI_BACKEND_DEFAULT_NAME:settings.renderBackend;
|
String curRenderBackend=settings.renderBackend.empty()?GUI_BACKEND_DEFAULT_NAME:settings.renderBackend;
|
||||||
if (ImGui::BeginCombo(_("Render backend"),curRenderBackend.c_str())) {
|
if (ImGui::BeginCombo(_("Render backend"),curRenderBackend.c_str())) {
|
||||||
#ifdef HAVE_RENDER_SDL
|
#ifdef HAVE_RENDER_SDL
|
||||||
|
@ -4671,6 +4716,8 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
|
||||||
settings.backupMaxCopies=conf.getInt("backupMaxCopies",5);
|
settings.backupMaxCopies=conf.getInt("backupMaxCopies",5);
|
||||||
|
|
||||||
settings.autoFillSave=conf.getInt("autoFillSave",0);
|
settings.autoFillSave=conf.getInt("autoFillSave",0);
|
||||||
|
|
||||||
|
settings.locale=conf.getString("locale","");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groups&GUI_SETTINGS_AUDIO) {
|
if (groups&GUI_SETTINGS_AUDIO) {
|
||||||
|
@ -5253,6 +5300,8 @@ void FurnaceGUI::writeConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
|
||||||
conf.set("backupMaxCopies",settings.backupMaxCopies);
|
conf.set("backupMaxCopies",settings.backupMaxCopies);
|
||||||
|
|
||||||
conf.set("autoFillSave",settings.autoFillSave);
|
conf.set("autoFillSave",settings.autoFillSave);
|
||||||
|
|
||||||
|
conf.set("locale",settings.locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// audio
|
// audio
|
||||||
|
|
|
@ -506,14 +506,18 @@ int main(int argc, char** argv) {
|
||||||
zsmOutName="";
|
zsmOutName="";
|
||||||
cmdOutName="";
|
cmdOutName="";
|
||||||
|
|
||||||
|
// load config for locale
|
||||||
|
e.prePreInit();
|
||||||
|
|
||||||
#ifdef HAVE_LOCALE
|
#ifdef HAVE_LOCALE
|
||||||
|
String reqLocale=e.getConfString("locale","");
|
||||||
const char* localeRet=NULL;
|
const char* localeRet=NULL;
|
||||||
if ((localeRet=TA_SETLOCALE(LC_CTYPE,"pt_BR"))==NULL) {
|
if ((localeRet=TA_SETLOCALE(LC_CTYPE,reqLocale.c_str()))==NULL) {
|
||||||
logE("could not set locale (CTYPE)!");
|
logE("could not set locale (CTYPE)!");
|
||||||
} else {
|
} else {
|
||||||
logV("locale: %s",localeRet);
|
logV("locale: %s",localeRet);
|
||||||
}
|
}
|
||||||
if ((localeRet=TA_SETLOCALE(LC_MESSAGES,"pt_BR"))==NULL) {
|
if ((localeRet=TA_SETLOCALE(LC_MESSAGES,reqLocale.c_str()))==NULL) {
|
||||||
logE("could not set locale (MESSAGES)!");
|
logE("could not set locale (MESSAGES)!");
|
||||||
} else {
|
} else {
|
||||||
logV("locale: %s",localeRet);
|
logV("locale: %s",localeRet);
|
||||||
|
|
|
@ -26,6 +26,13 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "momo.h"
|
#include "momo.h"
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
#include <SDL_rwops.h>
|
||||||
|
#define MO_FREE SDL_free
|
||||||
|
#else
|
||||||
|
#define MO_FREE free
|
||||||
|
#endif
|
||||||
|
|
||||||
static char curLocale[64];
|
static char curLocale[64];
|
||||||
static char tempPath[4096];
|
static char tempPath[4096];
|
||||||
|
|
||||||
|
@ -171,6 +178,28 @@ const char* momo_bindtextdomain(const char* domainName, const char* dirName) {
|
||||||
if (newDomain->mo==NULL) {
|
if (newDomain->mo==NULL) {
|
||||||
snprintf(tempPath,4096,"%s/%s/LC_MESSAGES/%s.mo",newDomain->path,curLocale,newDomain->name);
|
snprintf(tempPath,4096,"%s/%s/LC_MESSAGES/%s.mo",newDomain->path,curLocale,newDomain->name);
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
newDomain->mo=SDL_LoadFile(tempPath,&newDomain->moLen);
|
||||||
|
if (newDomain->mo==NULL) {
|
||||||
|
// try without country
|
||||||
|
char* cPos=strchr(curLocale,'_');
|
||||||
|
if (cPos) {
|
||||||
|
*cPos=0;
|
||||||
|
}
|
||||||
|
snprintf(tempPath,4096,"%s/%s/LC_MESSAGES/%s.mo",newDomain->path,curLocale,newDomain->name);
|
||||||
|
newDomain->mo=SDL_LoadFile(tempPath,&newDomain->moLen);
|
||||||
|
if (newDomain->mo==NULL) {
|
||||||
|
// give up
|
||||||
|
if (found) {
|
||||||
|
if (newDomain==curDomain) curDomain=NULL;
|
||||||
|
domainsRemove(newDomain);
|
||||||
|
}
|
||||||
|
free(newDomain);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#else
|
||||||
FILE* f=fopen(tempPath,"rb");
|
FILE* f=fopen(tempPath,"rb");
|
||||||
if (f==NULL) {
|
if (f==NULL) {
|
||||||
// try without country
|
// try without country
|
||||||
|
@ -255,12 +284,13 @@ const char* momo_bindtextdomain(const char* domainName, const char* dirName) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
#endif
|
||||||
|
|
||||||
// parse
|
// parse
|
||||||
struct MOHeader* header=(struct MOHeader*)newDomain->mo;
|
struct MOHeader* header=(struct MOHeader*)newDomain->mo;
|
||||||
if (header->magic!=0x950412de) {
|
if (header->magic!=0x950412de) {
|
||||||
// give up
|
// give up
|
||||||
free(newDomain->mo);
|
MO_FREE(newDomain->mo);
|
||||||
if (found) {
|
if (found) {
|
||||||
if (newDomain==curDomain) curDomain=NULL;
|
if (newDomain==curDomain) curDomain=NULL;
|
||||||
domainsRemove(newDomain);
|
domainsRemove(newDomain);
|
||||||
|
@ -273,7 +303,7 @@ const char* momo_bindtextdomain(const char* domainName, const char* dirName) {
|
||||||
header->transPtr+(header->stringCount*8)>newDomain->moLen ||
|
header->transPtr+(header->stringCount*8)>newDomain->moLen ||
|
||||||
header->hashPtr+(header->hashSize*4)>newDomain->moLen) {
|
header->hashPtr+(header->hashSize*4)>newDomain->moLen) {
|
||||||
// give up
|
// give up
|
||||||
free(newDomain->mo);
|
MO_FREE(newDomain->mo);
|
||||||
if (found) {
|
if (found) {
|
||||||
if (newDomain==curDomain) curDomain=NULL;
|
if (newDomain==curDomain) curDomain=NULL;
|
||||||
domainsRemove(newDomain);
|
domainsRemove(newDomain);
|
||||||
|
@ -300,7 +330,7 @@ const char* momo_bindtextdomain(const char* domainName, const char* dirName) {
|
||||||
// add to domain list
|
// add to domain list
|
||||||
if (!found) {
|
if (!found) {
|
||||||
if (!domainsInsert(newDomain)) {
|
if (!domainsInsert(newDomain)) {
|
||||||
if (newDomain->mo) free(newDomain->mo);
|
if (newDomain->mo) MO_FREE(newDomain->mo);
|
||||||
free(newDomain);
|
free(newDomain);
|
||||||
errno=ENOMEM;
|
errno=ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue