changeset 424:faf12767a6f1

Preparing for internationalization.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 31 Dec 2006 21:43:04 +0000
parents c0fdf3b3f3e6
children fa889b008608
files src/xmms-sid.c src/xmms-sid.h src/xs_config.c src/xs_fileinfo.c src/xs_length.c src/xs_stil.c
diffstat 6 files changed, 41 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/src/xmms-sid.c	Sat Dec 30 07:40:05 2006 +0000
+++ b/src/xmms-sid.c	Sun Dec 31 21:43:04 2006 +0000
@@ -198,13 +198,13 @@
 	/* Initialize song-length database */
 	xs_songlen_close();
 	if (xs_cfg.songlenDBEnable && (xs_songlen_init() != 0)) {
-		xs_error("Error initializing song-length database!\n");
+		xs_error(_("Error initializing song-length database!\n"));
 	}
 
 	/* Initialize STIL database */
 	xs_stil_close();
 	if (xs_cfg.stilDBEnable && (xs_stil_init() != 0)) {
-		xs_error("Error initializing STIL database!\n");
+		xs_error(_("Error initializing STIL database!\n"));
 	}
 }
 
@@ -316,14 +316,14 @@
 	/* Allocate audio buffer */
 	audioBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE);
 	if (audioBuffer == NULL) {
-		xs_error("Couldn't allocate memory for audio data buffer!\n");
+		xs_error(_("Couldn't allocate memory for audio data buffer!\n"));
 		goto xs_err_exit;
 	}
 
 	if (myStatus.oversampleEnable) {
 		oversampleBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE * myStatus.oversampleFactor);
 		if (oversampleBuffer == NULL) {
-			xs_error("Couldn't allocate memory for audio oversampling buffer!\n");
+			xs_error(_("Couldn't allocate memory for audio oversampling buffer!\n"));
 			goto xs_err_exit;
 		}
 	}
@@ -400,7 +400,7 @@
 
 		/* Initialize song */
 		if (!myStatus.sidPlayer->plrInitSong(&myStatus)) {
-			xs_error("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n",
+			xs_error(_("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n"),
 			      myTune->sidFilename, myStatus.currSong);
 			goto xs_err_exit;
 		}
@@ -412,8 +412,10 @@
 		
 		if (!xs_plugin_ip.output->
 		    open_audio(myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels)) {
-			xs_error("Couldn't open XMMS audio output (fmt=%x, freq=%i, nchan=%i)!\n", myStatus.audioFormat,
-			      myStatus.audioFrequency, myStatus.audioChannels);
+			xs_error(_("Couldn't open XMMS audio output (fmt=%x, freq=%i, nchan=%i)!\n"),
+				myStatus.audioFormat,
+				myStatus.audioFrequency,
+				myStatus.audioChannels);
 
 			XS_MUTEX_LOCK(xs_status);
 			xs_status.isError = TRUE;
@@ -451,7 +453,7 @@
 				/* Execute rate-conversion with filtering */
 				if (xs_filter_rateconv(audioBuffer, oversampleBuffer,
 						       myStatus.audioFormat, myStatus.oversampleFactor, audioGot) < 0) {
-					xs_error("Oversampling rate-conversion pass failed.\n");
+					xs_error(_("Oversampling rate-conversion pass failed.\n"));
 					XS_MUTEX_LOCK(xs_status);
 					xs_status.isError = TRUE;
 					XS_MUTEX_UNLOCK(xs_status);
@@ -567,7 +569,7 @@
 
 	/* Start the playing thread! */
 	if (pthread_create(&xs_decode_thread, NULL, xs_playthread, NULL) < 0) {
-		xs_error("Couldn't start playing thread!\n");
+		xs_error(_("Couldn't create playing thread!\n"));
 		xs_tuneinfo_free(xs_status.tuneInfo);
 		xs_status.tuneInfo = NULL;
 		xs_status.sidPlayer->plrDeleteSID(&xs_status);
@@ -764,7 +766,7 @@
 	gtk_widget_set_name(xs_subctrl, "xs_subctrl");
 	gtk_object_set_data(GTK_OBJECT(xs_subctrl), "xs_subctrl", xs_subctrl);
 
-	gtk_window_set_title(GTK_WINDOW(xs_subctrl), "Subtune Control");
+	gtk_window_set_title(GTK_WINDOW(xs_subctrl), _("Subtune Control"));
 	gtk_window_set_position(GTK_WINDOW(xs_subctrl), GTK_WIN_POS_MOUSE);
 	gtk_container_set_border_width(GTK_CONTAINER(xs_subctrl), 0);
 	gtk_window_set_policy(GTK_WINDOW(xs_subctrl), FALSE, FALSE, FALSE);
@@ -959,13 +961,15 @@
 	/* Allocate structure */
 	pResult = (t_xs_tuneinfo *) g_malloc0(sizeof(t_xs_tuneinfo));
 	if (!pResult) {
-		xs_error("Could not allocate memory for t_xs_tuneinfo ('%s')\n", pcFilename);
+		xs_error(_("Could not allocate memory for t_xs_tuneinfo ('%s')\n"),
+			pcFilename);
 		return NULL;
 	}
 
 	pResult->sidFilename = g_strdup(pcFilename);
 	if (!pResult->sidFilename) {
-		xs_error("Could not allocate sidFilename ('%s')\n", pcFilename);
+		xs_error(_("Could not allocate sidFilename ('%s')\n"),
+			pcFilename);
 		g_free(pResult);
 		return NULL;
 	}
@@ -973,7 +977,7 @@
 	/* Allocate space for subtune information */
 	pResult->subTunes = g_malloc0(sizeof(t_xs_subtuneinfo) * (nsubTunes + 1));
 	if (!pResult->subTunes) {
-		xs_error("Could not allocate memory for t_xs_subtuneinfo ('%s', %i)\n",
+		xs_error(_("Could not allocate memory for t_xs_subtuneinfo ('%s', %i)\n"),
 			pcFilename, nsubTunes);
 
 		g_free(pResult->sidFilename);
--- a/src/xmms-sid.h	Sat Dec 30 07:40:05 2006 +0000
+++ b/src/xmms-sid.h	Sun Dec 31 21:43:04 2006 +0000
@@ -217,6 +217,8 @@
 
 void	xs_error(const char *, ...);
 
+#define _(x) x
+
 #ifndef DEBUG_NP
 void	XSDEBUG(const char *, ...);
 #else
--- a/src/xs_config.c	Sat Dec 30 07:40:05 2006 +0000
+++ b/src/xs_config.c	Sun Dec 31 21:43:04 2006 +0000
@@ -307,8 +307,7 @@
 			break;
 
 		default:
-			xs_error
-			    ("Internal: Unsupported setting type found while reading configuration file. Please report to author!\n");
+			xs_error(_("Internal: Unsupported setting type found while reading configuration file. Please report to author!\n"));
 			break;
 		}
 	}
@@ -372,8 +371,7 @@
 			break;
 
 		default:
-			xs_error
-			    ("Internal: Unsupported setting type found while writing configuration file. Please report to author!\n");
+			xs_error(_("Internal: Unsupported setting type found while writing configuration file. Please report to author!\n"));
 			break;
 		}
 	}
--- a/src/xs_fileinfo.c	Sat Dec 30 07:40:05 2006 +0000
+++ b/src/xs_fileinfo.c	Sun Dec 31 21:43:04 2006 +0000
@@ -73,7 +73,7 @@
 }
 
 
-void xs_fileinfo_setsong(void)
+static void xs_fileinfo_setsong(void)
 {
 	gint n;
 
@@ -115,7 +115,7 @@
 
 
 
-void xs_fileinfo_subtune(GtkWidget * widget, void *data)
+static void xs_fileinfo_subtune(GtkWidget * widget, void *data)
 {
 	t_xs_stil_subnode *tmpNode;
 	GtkWidget *tmpItem, *tmpText;
@@ -167,7 +167,6 @@
 	GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu;
 	t_xs_tuneinfo *tmpInfo;
 	t_xs_stil_subnode *tmpNode;
-	gchar tmpStr[64];
 	gint n;
 
 	/* Current implementation leaves old fileinfo window untouched if
@@ -216,15 +215,16 @@
 	tmpOptionMenu = LUW("fileinfo_sub_tune");
 	tmpMenu = GTK_OPTION_MENU(tmpOptionMenu)->menu;
 
-	tmpMenuItem = gtk_menu_item_new_with_label("General info");
+	tmpMenuItem = gtk_menu_item_new_with_label(_("General info"));
 	gtk_widget_show(tmpMenuItem);
 	gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem);
 	gtk_signal_connect(GTK_OBJECT(tmpMenuItem), "activate", GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu);
 
 	/* Other menu items */
 	for (n = 1; n <= tmpInfo->nsubTunes; n++) {
+		gchar tmpStr[64];
 		if (xs_fileinfostil) {
-			g_snprintf(tmpStr, sizeof(tmpStr), "Tune #%i: ", n);
+			g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i: "), n);
 			
 			tmpNode = xs_fileinfostil->subTunes[n];
 			
@@ -235,7 +235,7 @@
 			else
 				xs_pnstrcat(tmpStr, sizeof(tmpStr), "---");
 		} else {
-			g_snprintf(tmpStr, sizeof(tmpStr), "Tune #%i", n);
+			g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i"), n);
 		}
 
 		tmpMenuItem = gtk_menu_item_new_with_label(tmpStr);
--- a/src/xs_length.c	Sat Dec 30 07:40:05 2006 +0000
+++ b/src/xs_length.c	Sun Dec 31 21:43:04 2006 +0000
@@ -110,7 +110,7 @@
 	/* Allocate new node */
 	tmpNode = (t_xs_sldb_node *) g_malloc0(sizeof(t_xs_sldb_node));
 	if (!tmpNode) {
-		xs_error("Error allocating new node. Fatal error.\n");
+		xs_error(_("Error allocating new node. Fatal error.\n"));
 		return NULL;
 	}
 
@@ -125,7 +125,7 @@
 	/* Get playtimes */
 	if (inLine[linePos] != 0) {
 		if (inLine[linePos] != '=') {
-			xs_error("'=' expected on column #%d.\n", linePos);
+			xs_error(_("'=' expected on column #%d.\n"), linePos);
 			xs_sldb_node_free(tmpNode);
 			return NULL;
 		} else {
@@ -147,7 +147,7 @@
 			/* Allocate memory for lengths */
 			tmpNode->sLengths = (gint *) g_malloc0(tmpNode->nLengths * sizeof(gint));
 			if (!tmpNode->sLengths) {
-				xs_error("Could not allocate memory for node.\n");
+				xs_error(_("Could not allocate memory for node.\n"));
 				xs_sldb_node_free(tmpNode);
 				return NULL;
 			}
@@ -192,7 +192,7 @@
 
 	/* Try to open the file */
 	if ((inFile = fopen(dbFilename, "ra")) == NULL) {
-		xs_error("Could not open SongLengthDB '%s'\n", dbFilename);
+		xs_error(_("Could not open SongLengthDB '%s'\n"), dbFilename);
 		return -1;
 	}
 
@@ -205,6 +205,8 @@
 		inLine[XS_BUF_SIZE - 1] = 0;
 		linePos = 0;
 		lineNum++;
+		
+		xs_findnext(inLine, &linePos);
 
 		/* Check if it is datafield */
 		if (isxdigit(inLine[linePos])) {
@@ -213,19 +215,19 @@
 			for (hashLen = 0; inLine[linePos] && isxdigit(inLine[linePos]); hashLen++, linePos++);
 
 			if (hashLen != XS_MD5HASH_LENGTH_CH) {
-				xs_error("Invalid MD5-hash in SongLengthDB file '%s' line #%d!\n",
+				xs_error(_("Invalid MD5-hash in SongLengthDB file '%s' line #%d!\n"),
 					dbFilename, lineNum);
 			} else {
 				/* Parse and add node to db */
 				if ((tmpNode = xs_sldb_read_entry(inLine)) != NULL) {
 					xs_sldb_node_insert(db, tmpNode);
 				} else {
-					xs_error("Invalid entry in SongLengthDB file '%s' line #%d!\n",
+					xs_error(_("Invalid entry in SongLengthDB file '%s' line #%d!\n"),
 						dbFilename, lineNum);
 				}
 			}
-		} else if ((inLine[linePos] != ';') && (inLine[linePos] != '[')) {
-			xs_error("Invalid line in SongLengthDB file '%s' line #%d\n",
+		} else if ((inLine[linePos] != ';') && (inLine[linePos] != '[') && (inLine[linePos] != 0)) {
+			xs_error(_("Invalid line in SongLengthDB file '%s' line #%d\n"),
 				dbFilename, lineNum);
 		}
 
--- a/src/xs_stil.c	Sat Dec 30 07:40:05 2006 +0000
+++ b/src/xs_stil.c	Sun Dec 31 21:43:04 2006 +0000
@@ -42,7 +42,7 @@
 			(nsubTunes + 1) * sizeof(t_xs_stil_subnode **));
 
 		if (!pNode->subTunes) {
-			xs_error("SubTune pointer structure realloc failed.\n");
+			xs_error(_("SubTune pointer structure realloc failed.\n"));
 			return FALSE;
 		}
 		
@@ -60,7 +60,7 @@
 			g_malloc0(sizeof(t_xs_stil_subnode));
 		
 		if (!pNode->subTunes[nsubTunes]) {
-			xs_error("SubTune structure malloc failed!\n");
+			xs_error(_("SubTune structure malloc failed!\n"));
 			return FALSE;
 		}
 	}
@@ -165,7 +165,8 @@
 
 	/* Try to open the file */
 	if ((inFile = fopen(dbFilename, "ra")) == NULL) {
-		xs_error("Could not open STILDB '%s'\n", dbFilename);
+		xs_error(_("Could not open STILDB '%s'\n"),
+			dbFilename);
 		return -1;
 	}