From 102e315102cd9aaf2007119a75d98ca1bacb3b76 Mon Sep 17 00:00:00 2001 From: HarpyWar Date: Tue, 24 Jun 2014 10:06:01 +0400 Subject: [PATCH] fix compile errors, add config values for i18n https://github.com/HarpyWar/pvpgn/issues/13 --- conf/bnetd.conf.in | 1 + conf/bnetd.conf.win32 | 1 + conf/bnhelp.conf.in | 2 +- src/bnetd/i18n.cpp | 18 +++++++++--------- src/bnetd/i18n.h | 1 - 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/conf/bnetd.conf.in b/conf/bnetd.conf.in index e5887ba23..7b12b1b26 100644 --- a/conf/bnetd.conf.in +++ b/conf/bnetd.conf.in @@ -79,6 +79,7 @@ storage_path = "file:mode=plain;dir=${LOCALSTATEDIR}/users;clan=${LOCALSTATEDIR} #----------------------------------------------------------------------------# filedir = "${LOCALSTATEDIR}/files" +i18ndir = "${SYSCONFDIR}/i18n" scriptdir = "${LOCALSTATEDIR}/lua" reportdir = "${LOCALSTATEDIR}/reports" chanlogdir = "${LOCALSTATEDIR}/chanlogs" diff --git a/conf/bnetd.conf.win32 b/conf/bnetd.conf.win32 index 7927a2512..7041a639a 100644 --- a/conf/bnetd.conf.win32 +++ b/conf/bnetd.conf.win32 @@ -59,6 +59,7 @@ storage_path = file:mode=plain;dir=var\users;clan=var\clans;team=var\teams;defau #----------------------------------------------------------------------------# filedir = files +i18ndir = conf\i18n scriptdir = lua reportdir = var\reports chanlogdir = var\chanlogs diff --git a/conf/bnhelp.conf.in b/conf/bnhelp.conf.in index 2fee341b2..c8e119ad9 100644 --- a/conf/bnhelp.conf.in +++ b/conf/bnhelp.conf.in @@ -450,7 +450,7 @@ -------------------------------------------------------- /rehash Forces the server to reload specified config. Set "all" to reload all configs. - = all | channels | realms | autoupdate | news | versioncheck | ipbans | helpfile | banners | tracker | commandgroups | aliasfile | transfile | tournament | icons | anongame | topiclist | lua + = all | i18n | channels | realms | autoupdate | news | versioncheck | ipbans | helpfile | banners | tracker | commandgroups | aliasfile | transfile | tournament | icons | anongame | topiclist | lua %clan -------------------------------------------------------- diff --git a/src/bnetd/i18n.cpp b/src/bnetd/i18n.cpp index 683562bfa..df465876b 100644 --- a/src/bnetd/i18n.cpp +++ b/src/bnetd/i18n.cpp @@ -51,8 +51,8 @@ #include "message.h" #include "helpfile.h" #include "channel.h" -#include "i18n.h" #include "prefs.h" +#include "i18n.h" #include "common/setup_after.h" namespace pvpgn @@ -72,8 +72,10 @@ namespace pvpgn } */ std::map > translations = std::map >(); - - std::vector languages{ + + const char * _find_string(char const * text, t_gamelang gamelang); + + const t_gamelang languages[12] = { GAMELANG_ENGLISH_UINT, /* enUS */ GAMELANG_GERMAN_UINT, /* deDE */ GAMELANG_CZECH_UINT, /* csCZ */ @@ -88,8 +90,6 @@ namespace pvpgn GAMELANG_CHINESE_T_UINT /* zhTW */ }; - const char * _find_string(char const * text, t_gamelang gamelang); - extern int i18n_reload(void) { @@ -108,9 +108,9 @@ namespace pvpgn std::string original, translate; // iterate language list - for (std::vector::iterator lang = languages.begin(); lang != languages.end(); ++lang) + for (int i = 0; i < (sizeof(languages) / sizeof(*languages)); i++) { - lang_filename = i18n_filename(filename, *lang); + lang_filename = i18n_filename(filename, languages[i]); if (FILE *f = fopen(lang_filename.c_str(), "r")) { fclose(f); @@ -158,10 +158,10 @@ namespace pvpgn if (translate[0] == '\0') { translate = original; - WARN2("empty localization for \"%s\", use original string (%s)", original, lang_filename.c_str()); + WARN2("empty localization for \"%s\", use original string (%s)", original.c_str(), lang_filename.c_str()); } } - translations[original][*lang] = translate; + translations[original][languages[i]] = translate; } INFO1("localization file loaded \"%s\"", lang_filename.c_str()); diff --git a/src/bnetd/i18n.h b/src/bnetd/i18n.h index 18368c027..6246186f2 100644 --- a/src/bnetd/i18n.h +++ b/src/bnetd/i18n.h @@ -23,7 +23,6 @@ namespace pvpgn namespace bnetd { - } }