← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~linuxdcpp-team/linuxdcpp/linuxdcpp-i18n] Rev 405: Translate wulfor

 

------------------------------------------------------------
revno: 405
committer: Steven Sheehy <steven.sheehy@xxxxxxxxx>
branch nick: linuxdcpp-i18n
timestamp: Fri 2010-11-19 01:29:51 -0600
message:
  Translate wulfor
modified:
  linux/IntlUtil.hh
  linux/wulfor.cc


--
lp:~linuxdcpp-team/linuxdcpp/linuxdcpp-i18n
https://code.launchpad.net/~linuxdcpp-team/linuxdcpp/linuxdcpp-i18n

Your team LinuxDC++ Team is subscribed to branch lp:~linuxdcpp-team/linuxdcpp/linuxdcpp-i18n.
To unsubscribe from this branch go to https://code.launchpad.net/~linuxdcpp-team/linuxdcpp/linuxdcpp-i18n/+edit-subscription
=== modified file 'linux/IntlUtil.hh'
--- linux/IntlUtil.hh	2010-11-12 08:07:06 +0000
+++ linux/IntlUtil.hh	2010-11-19 07:29:51 +0000
@@ -24,22 +24,41 @@
 
 #include <boost/format.hpp>
 #include <string>
+#include <exception>
 #include <glib/gi18n.h>
-
-static inline boost::format message_format(const char *text)
-{
-	boost::format fmt(text);
-	fmt.exceptions(boost::io::no_error_bits);
-	return fmt;
-}
-
-static inline boost::format message_format(const std::string &text)
-{
-	return message_format(text.c_str());
-}
-
-#define F_(text, params) (message_format(_(text)) params).str()
-#define P_(text, text_plural, params, n) (message_format(g_dngettext(NULL, text, text_plural, n)) params).str()
+#include <errno.h>
+
+class IntlUtil
+{
+	public:
+		// Initialize i18n support
+		static void initialize()
+		{
+			if (bindtextdomain(PACKAGE, _DATADIR "/locale") == NULL)
+				throw std::runtime_error(strerror(errno));
+
+			if (textdomain(PACKAGE) == NULL)
+				throw std::runtime_error(strerror(errno));
+
+			if (bind_textdomain_codeset(PACKAGE, "UTF-8") == NULL)
+				throw std::runtime_error(strerror(errno));
+		}
+
+		static inline boost::format message_format(const char *text)
+		{
+			boost::format fmt(text);
+			fmt.exceptions(boost::io::no_error_bits);
+			return fmt;
+		}
+
+		static inline boost::format message_format(const std::string &text)
+		{
+			return message_format(text.c_str());
+		}
+};
+
+#define F_(text, params) (IntlUtil::message_format(_(text)) params).str()
+#define P_(text, text_plural, params, n) (IntlUtil::message_format(g_dngettext(NULL, text, text_plural, n)) params).str()
 
 #endif /* LINUXDCPP_INTL_UTIL_HH */
 

=== modified file 'linux/wulfor.cc'
--- linux/wulfor.cc	2010-11-14 06:31:40 +0000
+++ linux/wulfor.cc	2010-11-19 07:29:51 +0000
@@ -44,25 +44,19 @@
 	CommandlineArgs() : show(FALSE), refresh(FALSE), version(FALSE), existing(FALSE) { }
 };
 
-
-void callBack(void* x, const std::string& a)
-{
-	std::cout << "Loading: " << a << std::endl;
-}
-
 void printVersionInfo() 
 {
-	std::cout << "Version information: " << std::endl;
-	std::cout << "\t" <<  APPNAME << " version: " << LINUXDCPP_VERSION_STRING << std::endl;
-	std::cout << "\t" <<  "DC++ Core version: " << VERSIONSTRING << std::endl;
-	std::cout << "\t" <<  "GLIB header version: " << GLIB_MAJOR_VERSION << "." << 
-		GLIB_MINOR_VERSION << "." << GLIB_MICRO_VERSION << std::endl;
-	std::cout << "\t" <<  "GLIB version: " << glib_major_version << "." 
-		<< glib_minor_version << "." << glib_micro_version << std::endl;
-	std::cout << "\t" <<  "GTK header version: " << GTK_MAJOR_VERSION << "." 
-		<< GTK_MINOR_VERSION << "." << GTK_MICRO_VERSION << std::endl;
-	std::cout << "\t" <<  "GTK version: " << gtk_major_version << "." 
-		<< gtk_minor_version << "." << gtk_micro_version << std::endl;
+	// TRANSLATORS: Application version printed on the command line.
+	std::cout << F_("%1% version: %2%", % APPNAME % LINUXDCPP_VERSION_STRING) << std::endl;
+
+	// TRANSLATORS: DC++ core library version printed on the command line.
+	std::cout << F_("DC++ library version: %1%", % VERSIONSTRING) << std::endl;
+
+	// TRANSLATORS: GTK+ version in major.minor.micro format printed on the command line.
+	std::cout << F_("GTK+ version: %1%.%2%.%3%", % gtk_major_version % gtk_minor_version % gtk_micro_version) << std::endl;
+
+	// TRANSLATORS: GLib version in major.minor.micro format printed on the command line.
+	std::cout << F_("GLib version: %1%.%2%.%3%", % glib_major_version % glib_minor_version % glib_micro_version) << std::endl;
 }
 
 void parseExtraArguments(int argc, char* argv[], CommandlineArgs* args)
@@ -102,7 +96,7 @@
 
 	if (!g_option_context_parse(context, argc, argv, &error))
 	{
-		g_print(_("Option parsing failed: %s\n"), error->message);
+		std::cerr << F_("Option parsing failed: %1%", % error->message) << std::endl;
 		return FALSE;
 	}
 	else
@@ -172,10 +166,7 @@
 	pathsMap[dcpp::Util::PATH_LOCALE] = _DATADIR "/locale";
 	dcpp::Util::initialize(pathsMap);
 
-	// Initialize i18n support
-	bindtextdomain(PACKAGE, _DATADIR "/locale");
-	textdomain(PACKAGE);
-	bind_textdomain_codeset(PACKAGE, "UTF-8");
+	IntlUtil::initialize();
 
 	if (!parseArguments(&argc, &argv, &args))
 	{
@@ -195,7 +186,7 @@
 
 		if (retval < 0) 
 		{
-			std::cout << _("Failed to communicate with existing instance: ") <<  dcpp::Util::translateError(retval) << std::endl;
+			std::cerr << F_("Failed to communicate with existing instance: %1%", % dcpp::Util::translateError(retval)) << std::endl;
 			return -1;
 		}
 
@@ -217,14 +208,12 @@
 
 	if (args.existing) // If we're still here and --existing was given, bail out since no running instance was found
 	{
-		std::cout << _("No running instance found") << std::endl;
+		std::cerr << _("No running instance found") << std::endl;
 		return 0;
 	}
 
-	printVersionInfo();
-
 	// Start the DC++ client core
-	dcpp::startup(callBack, NULL);
+	dcpp::startup(NULL, NULL);
 
 	dcpp::TimerManager::getInstance()->start();
 
@@ -244,7 +233,6 @@
 	WulforManager::stop();
 	WulforSettingsManager::deleteInstance();
 
-	std::cout << "Shutting down..." << std::endl;
 	dcpp::shutdown();
 
 	return 0;