if(cvar_string("menu_skin") != "")
{
draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
- fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
+ fh = fopen(language_file(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ);
}
if(fh < 0)
if(cvar_defstring("menu_skin") != "")
{
draw_currentSkin = strcat("gfx/menu/", cvar_defstring("menu_skin"));
- fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
+ fh = fopen(language_file(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ);
}
if(fh < 0)
{
draw_currentSkin = "gfx/menu/default";
- fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
+ fh = fopen(language_file(strcat(draw_currentSkin, "/skinvalues.txt")), FILE_READ);
}
draw_currentSkin = strzone(draw_currentSkin);
while((s = fgets(fh)))
unless in developer-only functions (e.g. *dumptree*)
- mark translatable strings with _()
- if a translatable string is a strcat monster, change it to sprintf
-- if code loads files with text, allow loading
- <filename>.cvar_string("prvm_language") in preference
+- if code loads files with text, use language_filename()
- test by:
find . -type f -not -name \*.po | xgettext -LC -k_ -f- gamecommand.qc
- interesting vi macros:
List of files to do:
-./xonotic/inputbox.c
-./xonotic/keybinder.c
-./xonotic/mainwindow.c
-./xonotic/maplist.c
-./xonotic/playerlist.c
-./xonotic/playermodel.c
-./xonotic/radiobutton.c
-./xonotic/rootdialog.c
-./xonotic/serverlist.c
-./xonotic/skinlist.c
./xonotic/slider_decibels.c
./xonotic/slider_picmip.c
./xonotic/slider_resolution.c
{
me.configureXonoticListBox(me);
// load the file
- me.bufferIndex = buf_load(strcat("xonotic-credits.txt.", cvar_string("prvm_language")));
+ me.bufferIndex = buf_load(language_filename("xonotic-credits.txt"));
if(me.bufferIndex < 0)
me.bufferIndex = buf_load("xonotic-credits.txt");
me.nItems = buf_getsize(me.bufferIndex);
string s;
Xonotic_KeyBinds_Count = 0;
- fh = fopen("keybinds.txt", FILE_READ);
+ fh = fopen(language_filename("keybinds.txt"), FILE_READ);
if(fh < 0)
return;
while((s = fgets(fh)))
void DemoButton_Click(entity me, entity other)
{
- if(me.text == "Do not press this button again!")
+ if(me.text == _("Do not press this button again!"))
DialogOpenButton_Click(me, other);
else
- me.setText(me, "Do not press this button again!");
+ me.setText(me, _("Do not press this button again!"));
}
void MainWindow_configureMainWindow(entity me)
m = MapInfo_BSPName_ByID(i);
if not(m)
{
- print("Huh? Can't play this (m is NULL). Refiltering so this won't happen again.\n");
+ print(_("Huh? Can't play this (m is NULL). Refiltering so this won't happen again.\n"));
+ me.refilter(me);
return;
}
if(MapInfo_CheckMap(m))
{
localcmd("\nmenu_loadmap_prepare\n");
if(cvar("menu_use_default_hostname"))
- localcmd("hostname \"", strdecolorize(cvar_string("_cl_name")), "'s Xonotic server\"\n");
+ localcmd("hostname \"", sprintf(_("%s's Xonotic Server"), strdecolorize(cvar_string("_cl_name"))), "\"\n");
MapInfo_LoadMap(m);
}
else
{
- print("Huh? Can't play this (invalid game type). Refiltering so this won't happen again.\n");
+ print(_("Huh? Can't play this (invalid game type). Refiltering so this won't happen again.\n"));
me.refilter(me);
+ return;
}
}
float sortbuf, glob, i;
string fn;
- glob = search_begin(get_model_datafilename(string_null, -1, "txt"), TRUE, TRUE);
+ glob = search_begin(language_filename(get_model_datafilename(string_null, -1, "txt")), TRUE, TRUE);
if (glob < 0)
return;
bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_SKIN, ftos(get_model_parameters_modelskin));
get_model_parameters_desc = strcat(get_model_parameters_desc, "\n");
if(get_model_parameters_sex)
- get_model_parameters_desc = strcat(get_model_parameters_desc, "\nSex: ", get_model_parameters_sex);
+ get_model_parameters_desc = strcat(get_model_parameters_desc, sprintf("\nSex: %s", get_model_parameters_sex));
if(get_model_parameters_weight)
- get_model_parameters_desc = strcat(get_model_parameters_desc, "\nWeight: ", ftos(get_model_parameters_weight), " kg");
+ get_model_parameters_desc = strcat(get_model_parameters_desc, sprintf("\nWeight: %g kg", get_model_parameters_weight));
if(get_model_parameters_age)
- get_model_parameters_desc = strcat(get_model_parameters_desc, "\nAge: ", ftos(get_model_parameters_age));
+ get_model_parameters_desc = strcat(get_model_parameters_desc, sprintf("\nAge: %g", get_model_parameters_age));
while(substring(get_model_parameters_desc, -1, 1) == "\n")
get_model_parameters_desc = substring(get_model_parameters_desc, 0, -2);
bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_DESC, get_model_parameters_desc);
if (me.numModels <= 0)
{
- draw_CenterText('0.5 0.5 0', "<no model found>", me.realFontSize, '1 1 1', 0.6, FALSE);
+ draw_CenterText('0.5 0.5 0', _("<no model found>"), me.realFontSize, '1 1 1', 0.6, FALSE);
return;
}
// still to be customized by user
/*
ATTRIB(XonoticDialog, closable, float, 1)
- ATTRIB(XonoticDialog, title, string, "Form1") // ;)
+ ATTRIB(XonoticDialog, title, string, _("Form1")) // ;)
ATTRIB(XonoticDialog, color, vector, '1 0.5 1')
ATTRIB(XonoticDialog, intendedWidth, float, 0)
ATTRIB(XonoticDialog, rows, float, 3)
if(me.ipAddressBox.focused || me.ipAddressBoxFocused < 0)
{
if(IsFavorite(me.ipAddressBox.text))
- me.favoriteButton.setText(me.favoriteButton, "Remove");
+ me.favoriteButton.setText(me.favoriteButton, _("Remove"));
else
- me.favoriteButton.setText(me.favoriteButton, "Bookmark");
+ me.favoriteButton.setText(me.favoriteButton, _("Bookmark"));
}
me.ipAddressBoxFocused = me.ipAddressBox.focused;
}
me.columnTypeOrigin = me.columnMapOrigin + me.columnMapSize + me.realFontSize_x;
me.columnPlayersOrigin = me.columnTypeOrigin + me.columnTypeSize + me.realFontSize_x;
- me.positionSortButton(me, me.sortButton1, me.columnPingOrigin, me.columnPingSize, "Ping", ServerList_PingSort_Click);
- me.positionSortButton(me, me.sortButton2, me.columnNameOrigin, me.columnNameSize, "Host name", ServerList_NameSort_Click);
- me.positionSortButton(me, me.sortButton3, me.columnMapOrigin, me.columnMapSize, "Map", ServerList_MapSort_Click);
- me.positionSortButton(me, me.sortButton4, me.columnTypeOrigin, me.columnTypeSize, "Type", ServerList_TypeSort_Click);
- me.positionSortButton(me, me.sortButton5, me.columnPlayersOrigin, me.columnPlayersSize, "Players", ServerList_PlayerSort_Click);
+ me.positionSortButton(me, me.sortButton1, me.columnPingOrigin, me.columnPingSize, _("Ping"), ServerList_PingSort_Click);
+ me.positionSortButton(me, me.sortButton2, me.columnNameOrigin, me.columnNameSize, _("Host name"), ServerList_NameSort_Click);
+ me.positionSortButton(me, me.sortButton3, me.columnMapOrigin, me.columnMapSize, _("Map"), ServerList_MapSort_Click);
+ me.positionSortButton(me, me.sortButton4, me.columnTypeOrigin, me.columnTypeSize, _("Type"), ServerList_TypeSort_Click);
+ me.positionSortButton(me, me.sortButton5, me.columnPlayersOrigin, me.columnPlayersSize, _("Players"), ServerList_PlayerSort_Click);
float f;
f = me.currentSortField;
{
s = search_getfilename(glob, i);
bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_NAME, substring(s, 9, strlen(s) - 24)); // the * part
- bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_TITLE, "<TITLE>");
- bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_AUTHOR, "<AUTHOR>");
+ bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_TITLE, _("<TITLE>"));
+ bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_AUTHOR, _("<AUTHOR>"));
bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_PREVIEW, strcat("/gfx/menu/", substring(s, 9, strlen(s) - 24), "/skinpreview"));
- fh = fopen(s, FILE_READ);
+ fh = fopen(language_file(s), FILE_READ);
if(fh < 0)
{
print("Warning: can't open skinvalues.txt file\n");
draw_Picture(me.columnPreviewOrigin * eX, s, me.columnPreviewSize * eX + eY, '1 1 1', 1);
s = me.skinParameter(me, i, SKINPARM_NAME);
- s = strcat(s, ": ", me.skinParameter(me, i, SKINPARM_TITLE));
+ s = sprintf(_("%s: %s"), s, me.skinParameter(me, i, SKINPARM_TITLE));
s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
draw_Text(me.realUpperMargin1 * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize))) * eX, s, me.realFontSize, SKINCOLOR_SKINLIST_TITLE, SKINALPHA_TEXT, 0);
string XonoticDecibelsSlider_valueToText(entity me, float v)
{
if(v < -33)
- return "OFF";
+ return _("OFF");
else if(v >= -0.1)
- return "MAX";
- return strcat(SUPER(XonoticDecibelsSlider).valueToText(me, v), " dB");
+ return _("MAX");
+ return sprintf(_("%s dB"), SUPER(XonoticDecibelsSlider).valueToText(me, v));
}
#endif
}
void XonoticResolutionSlider_addResolution(entity me, float w, float h, float pixelheight)
{
- me.addValue(me, strzone(strcat(ftos(w), "x", ftos(h))), strzone(strcat(ftos(w), " ", ftos(h), " ", ftos(pixelheight))));
+ me.addValue(me, strzone(sprintf(_("%dx%d"), w, h)), strzone(strcat(ftos(w), " ", ftos(h), " ", ftos(pixelheight))));
// FIXME (in case you ever want to dynamically instantiate this): THIS IS NEVER FREED
}
void XonoticResolutionSlider_configureXonoticResolutionSlider(entity me)
return i;
}
+string language_filename(string s)
+{
+ string fn;
+ float fh;
+ fn = cvar_string("prvm_language");
+ if(fn == "" || fn == "dump")
+ return s;
+ fn = strcat(s, ".", fn);
+ if((fh = fopen(fn, FILE_READ)) >= 0)
+ {
+ fclose(fh);
+ return fn;
+ }
+ return s;
+}
me.TR(me); \
me.TD(me, 1, 3, e = makeXonoticCheckBox(0, strzone(strcat("hud_panel_", hudpanel)), _("Enable panel"))); \
DIALOG_HUDPANEL_COMMON_NOTOGGLE()
+
+string language_filename(string s);