I wonder whether you like the attached patch, which was in bugzilla [1] for some time now but didn't receive any feedback. It ensures that ~/Templates is translated in the GUI. I remember an excessive discussion on ddl which discussed various ways of internationalizing folders. Some seemed to favor the apple way of doing things. They added a special files in the folders containing translations. However, since our translations are way more iterative and we release snapshots, this IMHO won't work properly. [1] http://bugzilla.gnome.org/show_bug.cgi?id=136836 -- Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-file-utilities.c =================================================================== RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-utilities.c,v retrieving revision 1.127 diff -u -p -r1.127 nautilus-file-utilities.c --- libnautilus-private/nautilus-file-utilities.c 13 Jul 2005 09:25:30 -0000 1.127 +++ libnautilus-private/nautilus-file-utilities.c 24 Aug 2005 14:13:30 -0000 @@ -501,36 +501,49 @@ nautilus_get_uri_shortname_for_display ( char *utf8_name, *name, *tmp; char *text_uri, *local_file; gboolean validated; + gboolean is_file_uri; const char *method; + static char *templates_dir = NULL; + + if (templates_dir == NULL) { + templates_dir = nautilus_get_templates_directory (); + } - validated = FALSE; - name = gnome_vfs_uri_extract_short_name (uri); - if (name == NULL) { - name = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD); - } else if (g_ascii_strcasecmp (uri->method_string, "file") == 0) { - text_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD); - local_file = gnome_vfs_get_local_path_from_uri (text_uri); - g_free (name); - name = g_filename_display_basename (local_file); - g_free (local_file); - g_free (text_uri); + is_file_uri = (g_ascii_strcasecmp (uri->method_string, "file") == 0); + + if (is_file_uri + && (strcmp (uri->text, templates_dir) == 0)) { + name = g_strdup (_("Templates")); validated = TRUE; - } else if (!gnome_vfs_uri_has_parent (uri)) { - /* Special-case the display name for roots that are not local files */ - method = nautilus_get_vfs_method_display_name (uri->method_string); - if (method == NULL) { - method = uri->method_string; - } - - if (name == NULL || - strcmp (name, GNOME_VFS_URI_PATH_STR) == 0) { + } else { + name = gnome_vfs_uri_extract_short_name (uri); + if (name == NULL) { + name = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD); + } else if (is_file_uri) { + text_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD); + local_file = gnome_vfs_get_local_path_from_uri (text_uri); g_free (name); - name = g_strdup (method); - } else { - tmp = name; - name = g_strdup_printf ("%s: %s", method, name); - g_free (tmp); + name = g_filename_display_basename (local_file); + g_free (local_file); + g_free (text_uri); + validated = TRUE; + } else if (!gnome_vfs_uri_has_parent (uri)) { + /* Special-case the display name for roots that are not local files */ + method = nautilus_get_vfs_method_display_name (uri->method_string); + if (method == NULL) { + method = uri->method_string; + } + + if (name == NULL || + strcmp (name, GNOME_VFS_URI_PATH_STR) == 0) { + g_free (name); + name = g_strdup (method); + } else { + tmp = name; + name = g_strdup_printf ("%s: %s", method, name); + g_free (tmp); + } } } Index: libnautilus-private/nautilus-file.c =================================================================== RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.c,v retrieving revision 1.370 diff -u -p -r1.370 nautilus-file.c --- libnautilus-private/nautilus-file.c 22 Aug 2005 21:17:58 -0000 1.370 +++ libnautilus-private/nautilus-file.c 24 Aug 2005 14:13:32 -0000 @@ -810,7 +810,32 @@ nautilus_file_can_execute (NautilusFile } /** - * nautilus_file_is_desktop_directory: + * nautilus_file_is_template_directory: + * + * Check whether this file is the template directory. + * + * @file: The file to check. + * + * Return value: TRUE if this is the physical desktop directory. + */ +gboolean +nautilus_file_is_template_directory (NautilusFile *file) +{ + GnomeVFSURI *dir_vfs_uri; + + dir_vfs_uri = file->details->directory->details->vfs_uri; + + if (dir_vfs_uri == NULL || + strcmp (dir_vfs_uri->method_string, "file") != 0) { + return FALSE; + } + + return ((strcmp (dir_vfs_uri->text, g_get_home_dir ()) == 0) + && (strcmp (file->details->relative_uri, "Templates") == 0)); +} + +/** + * nautilus_file_is_desktop_directory: * * Check whether this file is the desktop directory. * @@ -2677,6 +2702,8 @@ nautilus_file_get_display_name_nocopy (N if (file->details->got_link_info && file->details->display_name != NULL) { name = g_strdup (file->details->display_name); + } else if (nautilus_file_is_template_directory (file)) { + name = g_strdup (_("Templates")); } else { name = nautilus_file_get_name (file); if (name == NULL) { Index: libnautilus-private/nautilus-file.h =================================================================== RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.h,v retrieving revision 1.106 diff -u -p -r1.106 nautilus-file.h --- libnautilus-private/nautilus-file.h 22 Aug 2005 21:17:58 -0000 1.106 +++ libnautilus-private/nautilus-file.h 24 Aug 2005 14:13:32 -0000 @@ -155,6 +155,7 @@ gboolean nautilus_file_is gboolean nautilus_file_is_in_desktop (NautilusFile *file); gboolean nautilus_file_is_home (NautilusFile *file); gboolean nautilus_file_is_desktop_directory (NautilusFile *file); +gboolean nautilus_file_is_template_directory (NautilusFile *file); GnomeVFSResult nautilus_file_get_file_info_result (NautilusFile *file); gboolean nautilus_file_get_directory_item_count (NautilusFile *file, guint *count, Index: src/nautilus-pathbar.c =================================================================== RCS file: /cvs/gnome/nautilus/src/nautilus-pathbar.c,v retrieving revision 1.3 diff -u -p -r1.3 nautilus-pathbar.c --- src/nautilus-pathbar.c 25 Jul 2005 23:43:25 -0000 1.3 +++ src/nautilus-pathbar.c 24 Aug 2005 14:13:39 -0000 @@ -50,6 +50,7 @@ typedef enum { ROOT_BUTTON, HOME_BUTTON, DESKTOP_BUTTON, + TEMPLATES_BUTTON, VOLUME_BUTTON } ButtonType; @@ -203,6 +204,8 @@ desktop_location_changed_callback (gpoin static void nautilus_path_bar_init (NautilusPathBar *path_bar) { + char *templates_path; + GTK_WIDGET_SET_FLAGS (path_bar, GTK_NO_WINDOW); gtk_widget_set_redraw_on_allocate (GTK_WIDGET (path_bar), FALSE); @@ -215,6 +218,9 @@ nautilus_path_bar_init (NautilusPathBar path_bar->home_path = gnome_vfs_get_uri_from_local_path (g_get_home_dir ()); path_bar->root_path = g_strdup ("file:///"); desktop_is_home = (strcmp (path_bar->home_path, path_bar->desktop_path) == 0); + templates_path = g_build_filename (g_get_home_dir (), "Templates", NULL); + path_bar->templates_path = gnome_vfs_get_uri_from_local_path (templates_path); + g_free (templates_path); eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR, desktop_location_changed_callback, @@ -292,6 +298,10 @@ nautilus_path_bar_finalize (GObject *obj g_free (path_bar->desktop_path); path_bar->desktop_path = NULL; } + if (path_bar->templates_path) { + g_free (path_bar->templates_path); + path_bar->templates_path = NULL; + } if (path_bar->root_icon) { g_object_unref (path_bar->root_icon); @@ -1102,6 +1112,7 @@ get_button_image (NautilusPathBar *path_ g_free (icon_name); return path_bar->desktop_icon; + case TEMPLATES_BUTTON: default: return NULL; } @@ -1129,12 +1140,12 @@ get_dir_name (ButtonData *button_data) } else { return _("Desktop"); } + } else if (button_data->type == DESKTOP_BUTTON) { + return _("Desktop"); + } else if (button_data->type == TEMPLATES_BUTTON) { + return _("Templates"); } else { - if (button_data->type == DESKTOP_BUTTON) { - return _("Desktop"); - } else { - return button_data->dir_name; - } + return button_data->dir_name; } } @@ -1284,6 +1295,9 @@ find_button_type (NautilusPathBar *path if (path_bar->home_path != NULL && is_file_path_equal (path, path_bar->home_path)) { return HOME_BUTTON; } + if (path_bar->templates_path != NULL && is_file_path_equal (path, path_bar->templates_path)) { + return TEMPLATES_BUTTON; + } if (path_bar->desktop_path != NULL && is_file_path_equal (path, path_bar->desktop_path)) { if (!desktop_is_home) { return DESKTOP_BUTTON; @@ -1353,6 +1367,7 @@ make_directory_button (NautilusPathBar break; case HOME_BUTTON: case DESKTOP_BUTTON: + case TEMPLATES_BUTTON: case VOLUME_BUTTON: button_data->image = gtk_image_new (); button_data->label = gtk_label_new (NULL); Index: src/nautilus-pathbar.h =================================================================== RCS file: /cvs/gnome/nautilus/src/nautilus-pathbar.h,v retrieving revision 1.1 diff -u -p -r1.1 nautilus-pathbar.h --- src/nautilus-pathbar.h 8 Jul 2005 11:25:51 -0000 1.1 +++ src/nautilus-pathbar.h 24 Aug 2005 14:13:39 -0000 @@ -41,6 +41,7 @@ struct _NautilusPathBar char *root_path; char *home_path; char *desktop_path; + char *templates_path; GdkPixbuf *root_icon; GdkPixbuf *home_icon; Index: src/nautilus-spatial-window.c =================================================================== RCS file: /cvs/gnome/nautilus/src/nautilus-spatial-window.c,v retrieving revision 1.450 diff -u -p -r1.450 nautilus-spatial-window.c --- src/nautilus-spatial-window.c 23 Jul 2005 17:41:04 -0000 1.450 +++ src/nautilus-spatial-window.c 24 Aug 2005 14:13:39 -0000 @@ -530,15 +530,21 @@ location_button_clicked_callback (GtkWid NautilusFile *file; char *uri_string; - name = nautilus_get_uri_shortname_for_display (uri); + uri_string = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE); + + file = nautilus_file_get (uri_string); + if (nautilus_file_is_template_directory (file)) { + name = g_strdup (_("Templates")); + } else { + name = nautilus_get_uri_shortname_for_display (uri); + } + menu_item = gtk_image_menu_item_new_with_label (name); g_free (name); if (first_item == NULL) { first_item = menu_item; } - uri_string = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE); - file = nautilus_file_get (uri_string); g_object_ref (menu_item); nautilus_file_call_when_ready (file, NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY,
Attachment:
signature.asc
Description: This is a digitally signed message part