[PATCH] Improve view factory labels for translation



Currently, Nautilus strdup's many messages like
g_strdup ("problem with %s", _("List View")),
which leads to problems and gramatically faulty translations.
The attach patch is an attempt to fix this by exposing more labels
through the NautilusViewFactory that can be translated based on the
gramatical requirements of each view.

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-view-factory.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-view-factory.h,v
retrieving revision 1.2
diff -u -r1.2 nautilus-view-factory.h
--- libnautilus-private/nautilus-view-factory.h	22 Nov 2004 15:24:36 -0000	1.2
+++ libnautilus-private/nautilus-view-factory.h	9 Apr 2005 08:47:11 -0000
@@ -37,8 +37,12 @@
 
 struct _NautilusViewInfo {
 	char *id;
-	char *label;
-	char *label_with_mnemonic;
+	char *label;                       /* Foo View */
+	char *view_as_label;               /* View as Foo */
+	char *view_as_label_with_mnemonic; /* View as _Foo */
+	char *error_label;                 /* The foo view encountered an error. */
+	char *startup_error_label;         /* The foo view encountered an error while starting up. */
+	char *display_location_label;      /* Display this location with the foo view. */
 	NautilusView * (*create) (NautilusWindowInfo *window);
 	/* BONOBOTODO: More args here */
 	gboolean (*supports_uri) (const char *uri,
Index: src/nautilus-navigation-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-navigation-window.c,v
retrieving revision 1.429
diff -u -r1.429 nautilus-navigation-window.c
--- src/nautilus-navigation-window.c	4 Apr 2005 19:30:21 -0000	1.429
+++ src/nautilus-navigation-window.c	9 Apr 2005 08:47:11 -0000
@@ -604,14 +604,11 @@
 			  guint index)
 {
 	GtkWidget *menu_item;
-        char *menu_label;
 	const NautilusViewInfo *info;
 
 	info = nautilus_view_factory_lookup (identifier);
 
-	menu_label = g_strdup_printf (_("View as %s"), _(info->label));
-	menu_item = gtk_menu_item_new_with_mnemonic (menu_label);
-	g_free (menu_label);
+	menu_item = gtk_menu_item_new_with_mnemonic (_(info->view_as_label));
 
 	g_signal_connect_object (menu_item, "activate",
 				 G_CALLBACK (view_as_menu_switch_views_callback),
Index: src/nautilus-window-manage-views.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-manage-views.c,v
retrieving revision 1.350
diff -u -r1.350 nautilus-window-manage-views.c
--- src/nautilus-window-manage-views.c	4 Apr 2005 19:30:22 -0000	1.350
+++ src/nautilus-window-manage-views.c	9 Apr 2005 08:47:13 -0000
@@ -565,40 +565,52 @@
 	return g_strdup (info->label);
 }
 
-static void
-report_content_view_failure_to_user_internal (NautilusWindow *window,
-                                     	      NautilusView *view,
-                                     	      const char *message,
-					      const char *detail)
+char *
+nautilus_window_get_view_error_label (NautilusWindow *window)
 {
-	char *label;
+	const NautilusViewInfo *info;
+
+	info = nautilus_view_factory_lookup (nautilus_window_get_content_view_id (window));
 
-	label = nautilus_window_get_view_label (window);
-	message = g_strdup_printf (message, label);
-	eel_show_error_dialog (message, detail, _("View Failed"), GTK_WINDOW (window));
-	g_free (label);
+	return g_strdup (info->error_label);
+}
+
+char *
+nautilus_window_get_view_startup_error_label (NautilusWindow *window)
+{
+	const NautilusViewInfo *info;
+
+	info = nautilus_view_factory_lookup (nautilus_window_get_content_view_id (window));
+
+	return g_strdup (info->startup_error_label);
 }
 
 static void
 report_current_content_view_failure_to_user (NautilusWindow *window,
                                      	     NautilusView *view)
 {
-	report_content_view_failure_to_user_internal 
-		(window,
-		 view,
-		 _("The %s view encountered an error and can't continue."),
-		 _("You can choose another view or go to a different location."));
+	char *message;
+
+	message = nautilus_window_get_view_startup_error_label (window);
+	eel_show_error_dialog (message,
+			       _("You can choose another view or go to a different location."),
+			       _("View Failed"),
+			       GTK_WINDOW (window));
+	g_free (message);
 }
 
 static void
 report_nascent_content_view_failure_to_user (NautilusWindow *window,
                                      	     NautilusView *view)
 {
-	report_content_view_failure_to_user_internal 
-		(window,
-		 view,
-		 _("The %s view encountered an error while starting up."),
-		 _("The location cannot be displayed with this viewer."));
+	char *message;
+
+	message = nautilus_window_get_view_error_label (window);
+	eel_show_error_dialog (message,
+			       _("The location cannot be displayed with this viewer."),
+			       _("View Failed"),
+			       GTK_WINDOW (window));
+	g_free (message);
 }
 
 
Index: src/nautilus-window-manage-views.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-manage-views.h,v
retrieving revision 1.28
diff -u -r1.28 nautilus-window-manage-views.h
--- src/nautilus-window-manage-views.h	22 Nov 2004 15:24:37 -0000	1.28
+++ src/nautilus-window-manage-views.h	9 Apr 2005 08:47:13 -0000
@@ -51,6 +51,8 @@
                                                                        const char               *iid);
 const char             *nautilus_window_get_content_view_id           (NautilusWindow           *window);
 char                   *nautilus_window_get_view_label                (NautilusWindow           *window);
+char                   *nautilus_window_get_view_error_label          (NautilusWindow           *window);
+char                   *nautilus_window_get_view_startup_error_label  (NautilusWindow           *window);
 void                    nautilus_navigation_window_set_sidebar_panels (NautilusNavigationWindow *window,
                                                                        GList                    *view_identifier_list);
 
Index: src/nautilus-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.c,v
retrieving revision 1.444
diff -u -r1.444 nautilus-window.c
--- src/nautilus-window.c	22 Mar 2005 09:22:23 -0000	1.444
+++ src/nautilus-window.c	9 Apr 2005 08:47:13 -0000
@@ -662,23 +662,17 @@
 		       int index, /* extra_viewer is always index 0 */
 		       guint merge_id)
 {
-	char *tip;
 	const NautilusViewInfo *info;
-	char *label;
 	GtkRadioAction *action;
 	char *action_name;
 	ActivateViewData *data;
 
 	info = nautilus_view_factory_lookup (identifier);
-
-	label = g_strdup_printf (_("View as %s"), _(info->label_with_mnemonic));
-	tip = g_strdup_printf (_("Display this location with \"%s\""),
-			       _(info->label));
 	
 	action_name = g_strdup_printf ("view_as_%d", index);
 	action = gtk_radio_action_new (action_name,
-				       label,
-				       tip,
+				       _(info->view_as_label_with_mnemonic),
+				       _(info->display_location_label),
 				       NULL,
 				       0);
 
@@ -690,9 +684,6 @@
 		   as it can get deleted/changed later */
 		window->details->view_as_radio_action = action;
 	}
-	
-	g_free (label);
-	g_free (tip);
 
 	data = g_new (ActivateViewData, 1);
 	data->window = window;
Index: src/file-manager/fm-desktop-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-desktop-icon-view.c,v
retrieving revision 1.221
diff -u -r1.221 fm-desktop-icon-view.c
--- src/file-manager/fm-desktop-icon-view.c	25 Mar 2005 15:37:33 -0000	1.221
+++ src/file-manager/fm-desktop-icon-view.c	9 Apr 2005 08:47:14 -0000
@@ -798,7 +798,11 @@
 static NautilusViewInfo fm_desktop_icon_view = {
 	FM_DESKTOP_ICON_VIEW_ID,
 	N_("Desktop"),
-	N_("_Desktop"),
+	N_("View as Desktop"),
+	N_("View as _Desktop"),
+	N_("The desktop view encountered an error."),
+	N_("The desktop view encountered an error while starting up."),
+	N_("Display this location with the desktop view."),
 	fm_desktop_icon_view_create,
 	fm_desktop_icon_view_supports_uri
 };
@@ -807,7 +811,11 @@
 fm_desktop_icon_view_register (void)
 {
 	fm_desktop_icon_view.label = _(fm_desktop_icon_view.label);
-	fm_desktop_icon_view.label_with_mnemonic = _(fm_desktop_icon_view.label_with_mnemonic);
+	fm_desktop_icon_view.view_as_label = _(fm_desktop_icon_view.view_as_label);
+	fm_desktop_icon_view.view_as_label_with_mnemonic = _(fm_desktop_icon_view.view_as_label_with_mnemonic);
+	fm_desktop_icon_view.error_label = _(fm_desktop_icon_view.error_label);
+	fm_desktop_icon_view.startup_error_label = _(fm_desktop_icon_view.startup_error_label);
+	fm_desktop_icon_view.display_location_label = _(fm_desktop_icon_view.display_location_label);
 	
 	nautilus_view_factory_register (&fm_desktop_icon_view);
 }
Index: src/file-manager/fm-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-icon-view.c,v
retrieving revision 1.305
diff -u -r1.305 fm-icon-view.c
--- src/file-manager/fm-icon-view.c	16 Jan 2005 16:07:26 -0000	1.305
+++ src/file-manager/fm-icon-view.c	9 Apr 2005 08:47:15 -0000
@@ -2671,7 +2671,11 @@
 static NautilusViewInfo fm_icon_view = {
 	FM_ICON_VIEW_ID,
 	N_("Icons"),
-	N_("_Icons"),
+	N_("View as Icons"),
+	N_("View as _Icons"),
+	N_("The icon view encountered an error."),
+	N_("The icon view encountered an error while starting up."),
+	N_("Display this location with the icon view."),
 	fm_icon_view_create,
 	fm_icon_view_supports_uri
 };
@@ -2680,7 +2684,11 @@
 fm_icon_view_register (void)
 {
 	fm_icon_view.label = _(fm_icon_view.label);
-	fm_icon_view.label_with_mnemonic = _(fm_icon_view.label_with_mnemonic);
+	fm_icon_view.view_as_label = _(fm_icon_view.view_as_label);
+	fm_icon_view.view_as_label_with_mnemonic = _(fm_icon_view.view_as_label_with_mnemonic);
+	fm_icon_view.error_label = _(fm_icon_view.error_label);
+	fm_icon_view.startup_error_label = _(fm_icon_view.startup_error_label);
+	fm_icon_view.display_location_label = _(fm_icon_view.display_location_label);
 	
 	nautilus_view_factory_register (&fm_icon_view);
 }
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.237
diff -u -r1.237 fm-list-view.c
--- src/file-manager/fm-list-view.c	27 Feb 2005 19:45:59 -0000	1.237
+++ src/file-manager/fm-list-view.c	9 Apr 2005 08:47:16 -0000
@@ -2309,7 +2309,11 @@
 static NautilusViewInfo fm_list_view = {
 	FM_LIST_VIEW_ID,
 	N_("List"),
-	N_("_List"),
+	N_("View as List"),
+	N_("View as _List"),
+	N_("The list view encountered an error."),
+	N_("The list view encountered an error while starting up."),
+	N_("Display this location with the list view."),
 	fm_list_view_create,
 	fm_list_view_supports_uri
 };
@@ -2318,7 +2322,11 @@
 fm_list_view_register (void)
 {
 	fm_list_view.label = _(fm_list_view.label);
-	fm_list_view.label_with_mnemonic = _(fm_list_view.label_with_mnemonic);
-	
+	fm_list_view.view_as_label = _(fm_list_view.view_as_label);
+	fm_list_view.view_as_label_with_mnemonic = _(fm_list_view.view_as_label_with_mnemonic);
+	fm_list_view.error_label = _(fm_list_view.error_label);
+	fm_list_view.startup_error_label = _(fm_list_view.startup_error_label);
+	fm_list_view.display_location_label = _(fm_list_view.display_location_label);
+
 	nautilus_view_factory_register (&fm_list_view);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]