diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2009-06-13 17:18:06 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2009-06-13 17:18:06 +0000 |
| commit | bc20e9c433c1c7bd2a9516a936d1d7ffee1e90f2 (patch) | |
| tree | 172eb47c01b26969ccda334006f83859f43abe90 | |
| parent | 6d9ccee95dd99fecda3a6ba62c2768b4d39f69e5 (diff) | |
| download | zcatch-bc20e9c433c1c7bd2a9516a936d1d7ffee1e90f2.tar.gz zcatch-bc20e9c433c1c7bd2a9516a936d1d7ffee1e90f2.zip | |
localization update
| -rw-r--r-- | data/languages/swedish.txt | 305 | ||||
| -rw-r--r-- | scripts/update_localization.py | 4 | ||||
| -rw-r--r-- | src/game/client/components/menus.cpp | 29 | ||||
| -rw-r--r-- | src/game/client/components/menus_browser.cpp | 3 | ||||
| -rw-r--r-- | src/game/client/components/menus_settings.cpp | 49 | ||||
| -rw-r--r-- | src/game/client/gameclient.cpp | 13 | ||||
| -rw-r--r-- | src/game/client/gameclient.hpp | 1 | ||||
| -rw-r--r-- | src/game/localization.cpp | 44 | ||||
| -rw-r--r-- | src/game/localization.hpp | 2 |
9 files changed, 270 insertions, 180 deletions
diff --git a/data/languages/swedish.txt b/data/languages/swedish.txt index 705f02b0..c67bfa8f 100644 --- a/data/languages/swedish.txt +++ b/data/languages/swedish.txt @@ -4,208 +4,265 @@ Fullscreen == Fullskärm -Are you sure that you want to quit? -== Är du säker på att du vill avsluta? - Loading == Laddar -Mouse sens. -== Muskänslighet +Next Weapon: +== Nästa vapen: -Reset to defaults -== Återställ till standard +Internet +== Internet -Mute when not active -== +Use sounds +== Använd ljudeffekter -Controls -== Kontroller +Body +== Kropp -Current -== Nuvarande +Show name plates +== Visa namnskyltar -Sound volume -== Ljud volym +Quality Textures +== Kvalitets texturer -Dynamic Camera -== Dynamisk kamera +News +== Nyheter -Enter -== Fortsätt +Sound +== Ljud -Internet -== Internet +Ok +== Ok + +Call Vote +== Starta omröstning + +LAN +== LAN + +FSAA samples +== FSAA samplingar + +Hammer: +== Hammare: + +Welcome to Teeworlds +== Välkommen till Teeworlds + +Voting +== Röstning + +Sat. +== Mättnad + +Try again +== Försök igen + +Prev. Weapon: +== Föregående vapen: + +Skins +== Utseende Quit == Avsluta -Use sounds -== Använd ljudeffekter +Controls +== Kontroller + +Dynamic Camera +== Dynamisk kamera + +Show only supported +== Visa endast upplösningar som stöds + +Miscellaneous +== Övrigt Nickname: == Smeknamn: -Movement -== Förflyttning +Game +== Spel -Body -== Kropp +Screenshot: +== Skärmdump -Hue -== Nyans +Grenade: +== Granater: + +Team Chat: +== Lagchatt: + +Settings +== Inställningar + +Custom colors +== Egna färger + +Emoticon: +== Känsloikon + +Shotgun: +== Hagelgevär: UI Color == Gränssnittfärg -Demos -== Demon +Sample rate +== Samplingsfrekvens -Texture Compression -== Texturkompression +Move Left: +== Gå vänster: -Show only supported -== Visa endast upplösningar som stöds +V-Sync +== V-Sync + +Chat +== Chatt + +Yes +== Ja + +Console: +== Konsol: + +High Detail +== Extra detaljer No == Nej -Connecting to -== Ansluter till +Mute when not active +== Stäng av ljudet när spelet inte är aktivt -Miscellaneous -== Övrigt +Password Incorrect +== Felaktigt lösenord -Switch weapon on pickup -== Byt vapen vid upplock +Sound volume +== Ljud volym -Show name plates -== Visa namnskyltar +Vote No: +== Rösta nej: -Quality Textures -== Kvalitets texturer +Movement +== Förflyttning -Game -== Spel +Hue +== Nyans -Favorites -== Favoriter +As this is the first time you launch the game, please enter your nick name below. It's recommended that you check the settings to adjust them to your liking before joining a server. +== Detta är första gången du startar spelet, var vänligen skriv in ditt smeknamn här nedanför. Det är rekommenderat att du kollar inställningarna och justerar dom till din preferens innan du börjar spela. -Graphics -== Grafik +Rifle: +== Gevär: -Alpha -== Genomskinlighet +Switch weapon on pickup +== Byt vapen vid upplock -Name: -== Namn: +Fire: +== Skjuta: Weapon == Vapen -Sound -== Ljud +Display Modes +== Skärmlägen -The server is running a non-standard tuning on a pure game mode. -== +Move Right: +== Gå höger -Ok -== Ok +Lht. +== Ljusstyrka -Call Vote -== +Chat: +== Chatt: -Settings -== Inställningar +Remote Console: +== Serverkonsol: -You must restart the game for all settings to take effect. -== Du måste starta om spelet för att ändringarna skall gälla. +Feet +== Fötter -Custom colors -== Egna färger +Demos +== Demon -Try again -== Försök igen +Abort +== Avbryt -Disconnected -== +Always show name plates +== Visa alltid namnskyltar -Display Modes -== +Are you sure that you want to quit? +== Är du säker på att du vill avsluta? -FSAA samples -== +Scoreboard: +== Poänglista -Downloading map -== Laddar ner karta +Mouse sens. +== Muskänslighet -Welcome to Teeworlds -== Välkommen till Teeworlds +Reset to defaults +== Återställ till standard -News -== Nyheter +Current +== Nuvarande -Lht. -== Ljusstyrka +Hook: +== Haken: -Voting -== Röstning +Texture Compression +== Texturkompression -Sat. -== Mättnad +Connecting to +== Ansluter till -Password Incorrect -== Felaktigt lösenord +Favorites +== Favoriter -LAN -== LAN +Graphics +== Grafik -Sample rate -== +Alpha +== Alpha -Password: -== Lösenord: +Name: +== Namn: -As this is the first time you launch the game, please enter your nick name below. It's recommended that you check the settings to adjust them to your liking before joining a server. -== Detta är första gången du startar spelet, var vänligen skriv in ditt smeknamn här nedanför. Det är rekommenderat att du kollar inställningarna och justerar dom till din preferens innan du börjar spela. +Disconnected +== Frånkopplad -V-Sync -== V-Sync +You must restart the game for all settings to take effect. +== Du måste starta om spelet för att ändringarna skall gälla. -Skins -== Utseende +Downloading map +== Laddar ner karta -Feet -== Fötter +Enter +== Fortsätt -Player -== Spelare +Jump: +== Hoppa: -Abort -== Avbryt +Password: +== Lösenord: -Always show name plates -== Visa alltid namnskyltar +Player +== Spelare -Chat -== Chat +Vote Yes: +== Rösta ja: Server Info == Server info. -Yes -== Ja - -High Detail -== Extra detaljer +Pistol: +== Pistol: ##### needs translation #### -##### old translations #### - -Try Again -== Försök igen +The server is running a non-standard tuning on a pure game mode. +== -sasdf -== asdfsa +##### old translations #### diff --git a/scripts/update_localization.py b/scripts/update_localization.py index 7dbc90f5..087f55a4 100644 --- a/scripts/update_localization.py +++ b/scripts/update_localization.py @@ -48,7 +48,7 @@ def generate_languagefile(outputfilename, srctable, loctable): print >>f, "##### translated strings #####" print >>f, "" for k in srctable: - if k in loctable: + if k in loctable and len(loctable[k]): print >>f, k print >>f, "==", loctable[k] print >>f, "" @@ -58,7 +58,7 @@ def generate_languagefile(outputfilename, srctable, loctable): print >>f, "##### needs translation ####" print >>f, "" for k in srctable: - if not k in loctable: + if not k in loctable or len(loctable[k]) == 0: print >>f, k print >>f, "==", srctable[k] print >>f, "" diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 398bd1ae..932597f7 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -12,9 +12,7 @@ #include "skins.hpp" #include <engine/e_client_interface.h> -extern "C" { -#include <engine/e_linereader.h> -} + #include <game/version.hpp> #include <game/generated/g_protocol.hpp> @@ -622,32 +620,7 @@ void MENUS::render_news(RECT main_view) void MENUS::on_init() { - LINEREADER lr; - IOHANDLE io = io_open("swedish.txt", IOFLAG_READ); - linereader_init(&lr, io); - char *line; - while((line = linereader_get(&lr))) - { - if(!str_length(line)) - continue; - - char *replacement = linereader_get(&lr); - if(!replacement) - { - dbg_msg("", "unexpected end of file"); - break; - } - - if(replacement[0] != '=' || replacement[1] != '=' || replacement[2] != ' ') - { - dbg_msg("", "malform replacement line for '%s'", line); - continue; - } - replacement += 3; - localization.add_string(line, replacement); - } - /* array<string> my_strings; array<string>::range r2; diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index a7751347..3d58af93 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -9,6 +9,7 @@ #include <game/client/ui.hpp> #include <game/client/render.hpp> #include "menus.hpp" +#include <game/localization.hpp> #include <game/version.hpp> void MENUS::render_serverbrowser_serverlist(RECT view) @@ -27,7 +28,7 @@ void MENUS::render_serverbrowser_serverlist(RECT view) { int id; int sort; - const char *caption; + LOC_CONSTSTRING caption; int direction; float width; int flags; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index beeab046..58678b80 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -13,6 +13,7 @@ #include <game/client/render.hpp> #include <game/client/gameclient.hpp> #include <game/client/animstate.hpp> +#include <game/localization.hpp> #include "binds.hpp" #include "menus.hpp" @@ -248,35 +249,35 @@ typedef void (*assign_func_callback)(CONFIGURATION *config, int value); typedef struct { - const char *name; + LOC_CONSTSTRING name; const char *command; int keyid; } KEYINFO; -// TODO: localize KEYINFO keys[] = { - { "Move Left:", "+left", 0}, - { "Move Right:", "+right", 0 }, - { "Jump:", "+jump", 0 }, - { "Fire:", "+fire", 0 }, - { "Hook:", "+hook", 0 }, - { "Hammer:", "+weapon1", 0 }, - { "Pistol:", "+weapon2", 0 }, - { "Shotgun:", "+weapon3", 0 }, - { "Grenade:", "+weapon4", 0 }, - { "Rifle:", "+weapon5", 0 }, - { "Next Weapon:", "+nextweapon", 0 }, - { "Prev. Weapon:", "+prevweapon", 0 }, - { "Vote Yes:", "vote yes", 0 }, - { "Vote No:", "vote no", 0 }, - { "Chat:", "chat all", 0 }, - { "Team Chat:", "chat team", 0 }, - { "Emoticon:", "+emote", 0 }, - { "Console:", "toggle_local_console", 0 }, - { "Remote Console:", "toggle_remote_console", 0 }, - { "Screenshot:", "screenshot", 0 }, - { "Scoreboard:", "+scoreboard", 0 }, + // we need to do localize so the scripts can pickup the string + { localize("Move Left:"), "+left", 0}, + { localize("Move Right:"), "+right", 0 }, + { localize("Jump:"), "+jump", 0 }, + { localize("Fire:"), "+fire", 0 }, + { localize("Hook:"), "+hook", 0 }, + { localize("Hammer:"), "+weapon1", 0 }, + { localize("Pistol:"), "+weapon2", 0 }, + { localize("Shotgun:"), "+weapon3", 0 }, + { localize("Grenade:"), "+weapon4", 0 }, + { localize("Rifle:"), "+weapon5", 0 }, + { localize("Next Weapon:"), "+nextweapon", 0 }, + { localize("Prev. Weapon:"), "+prevweapon", 0 }, + { localize("Vote Yes:"), "vote yes", 0 }, + { localize("Vote No:"), "vote no", 0 }, + { localize("Chat:"), "chat all", 0 }, + { localize("Team Chat:"), "chat team", 0 }, + { localize("Emoticon:"), "+emote", 0 }, + { localize("Console:"), "toggle_local_console", 0 }, + { localize("Remote Console:"), "toggle_remote_console", 0 }, + { localize("Screenshot:"), "screenshot", 0 }, + { localize("Scoreboard:"), "+scoreboard", 0 }, }; const int key_count = sizeof(keys) / sizeof(KEYINFO); @@ -292,7 +293,7 @@ void MENUS::ui_do_getbuttons(int start, int stop, RECT view) ui_do_label(&label, key.name, 14.0f, -1); int oldid = key.keyid; - int newid = ui_do_key_reader((void *)keys[i].name, &button, oldid); + int newid = ui_do_key_reader((void *)&keys[i].name, &button, oldid); if(newid != oldid) { gameclient.binds->bind(oldid, ""); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index ae501fa2..834aa29b 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -6,6 +6,7 @@ #include <game/generated/gc_data.hpp> #include <game/layers.hpp> +#include <game/localization.hpp> #include "render.hpp" #include "gameclient.hpp" @@ -158,7 +159,10 @@ void GAMECLIENT::on_console_init() input.add(&emoticon); input.add(controls); input.add(binds); - + + // + MACRO_REGISTER_COMMAND("language", "s", CFGFLAG_CLIENT, con_language, this, "Sets the language"); + // add the some console commands MACRO_REGISTER_COMMAND("team", "i", CFGFLAG_CLIENT, con_team, this, "Switch team"); MACRO_REGISTER_COMMAND("kill", "", CFGFLAG_CLIENT, con_kill, this, "Kill yourself"); @@ -881,3 +885,10 @@ void GAMECLIENT::con_kill(void *result, void *user_data) { ((GAMECLIENT*)user_data)->send_kill(-1); } + +void GAMECLIENT::con_language(void *result, void *user_data) +{ + char buf[128]; + str_format(buf, sizeof(buf), "data/languages/%s.txt", console_arg_string(result, 0)); + localization.load(buf); +} diff --git a/src/game/client/gameclient.hpp b/src/game/client/gameclient.hpp index 35b95f27..7d8c3701 100644 --- a/src/game/client/gameclient.hpp +++ b/src/game/client/gameclient.hpp @@ -31,6 +31,7 @@ class GAMECLIENT int predicted_tick; int last_new_predicted_tick; + static void con_language(void *result, void *user_data); static void con_team(void *result, void *user_data); static void con_kill(void *result, void *user_data); diff --git a/src/game/localization.cpp b/src/game/localization.cpp index cfc659f5..58ec539c 100644 --- a/src/game/localization.cpp +++ b/src/game/localization.cpp @@ -1,6 +1,10 @@ #include "localization.hpp" +extern "C" { +#include <engine/e_linereader.h> +} + static unsigned str_hash(const char *str) { unsigned hash = 5381; @@ -43,8 +47,48 @@ void LOCALIZATIONDATABASE::add_string(const char *org_str, const char *new_str) s.hash = str_hash(org_str); s.replacement = new_str; strings.add(s); +} + +bool LOCALIZATIONDATABASE::load(const char *filename) +{ + LINEREADER lr; + IOHANDLE io = io_open(filename, IOFLAG_READ); + if(!io) + return false; + + dbg_msg("localization", "loaded '%s'", filename); + strings.clear(); + + linereader_init(&lr, io); + char *line; + while((line = linereader_get(&lr))) + { + if(!str_length(line)) + continue; + + if(line[0] == '#') // skip comments + continue; + + char *replacement = linereader_get(&lr); + if(!replacement) + { + dbg_msg("", "unexpected end of file"); + break; + } + + if(replacement[0] != '=' || replacement[1] != '=' || replacement[2] != ' ') + { + dbg_msg("", "malform replacement line for '%s'", line); + continue; + } + + replacement += 3; + localization.add_string(line, replacement); + } + current_version++; + return true; } const char *LOCALIZATIONDATABASE::find_string(unsigned hash) diff --git a/src/game/localization.hpp b/src/game/localization.hpp index 87b6e2f8..de6849d4 100644 --- a/src/game/localization.hpp +++ b/src/game/localization.hpp @@ -18,6 +18,8 @@ class LOCALIZATIONDATABASE public: LOCALIZATIONDATABASE(); + bool load(const char *filename); + int version() { return current_version; } void add_string(const char *org_str, const char *new_str); |