diff options
author | Darin Adler <darin@src.gnome.org> | 2001-02-28 21:34:38 +0000 |
---|---|---|
committer | Darin Adler <darin@src.gnome.org> | 2001-02-28 21:34:38 +0000 |
commit | 91b66e65de6923d08a4003946ff99d71e7729343 (patch) | |
tree | 013503b6819f97372234a18b3b91fcc284eb8c6d | |
parent | e4abb4d117c35c85c721579e615127063f986231 (diff) | |
download | nautilus-91b66e65de6923d08a4003946ff99d71e7729343.tar.gz |
reviewed by: John Sullivan <sullivan@eazel.com>
* check-strings.pl:
* check-strings-functions:
* check-strings-patterns:
New script and correspoinding config files to help us find
untranslated strings. It's going to take some effort to make
this an easy-to-use tool.
* components/rpmview/nautilus-rpm-view.c:
(nautilus_rpm_view_initialize): Fixed string that would not
get translated properly since it was using N_ and nothing
was going to use _() on it.
(nautilus_rpm_view_update_from_uri): Marked strings for
translation as requested in bug report 7149.
(nautilus_rpm_view_verify_files): Format tweak.
(nautilus_rpm_view_drag_data_received): Remove old dead code.
* libnautilus-extensions/nautilus-tabs.c: (draw_tab_piece_aa):
Change to use C-style comments, not C++.
* src/nautilus-application.c: (check_required_directories): Mark
strings for translation that we had missed before.
* src/nautilus-first-time-druid.c: Fix port string define so it
doesn't have to be repeated twice (and doesn't show up as an
"untranslated string").
* src/nautilus-about.c: Formatting tweak.
* src/nautilus-location-bar.c: Fix typo.
-rw-r--r-- | ChangeLog | 32 | ||||
-rw-r--r-- | check-strings-functions | 11 | ||||
-rw-r--r-- | check-strings-patterns | 66 | ||||
-rwxr-xr-x | check-strings.pl | 173 | ||||
-rw-r--r-- | components/rpmview/nautilus-rpm-view.c | 22 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-tabs.c | 4 | ||||
-rw-r--r-- | libnautilus-private/nautilus-tabs.c | 4 | ||||
-rw-r--r-- | src/nautilus-about.c | 2 | ||||
-rw-r--r-- | src/nautilus-application.c | 16 | ||||
-rw-r--r-- | src/nautilus-first-time-druid.c | 2 | ||||
-rw-r--r-- | src/nautilus-location-bar.c | 2 |
11 files changed, 306 insertions, 28 deletions
@@ -1,3 +1,35 @@ +2001-02-28 Darin Adler <darin@eazel.com> + + reviewed by: John Sullivan <sullivan@eazel.com> + + * check-strings.pl: + * check-strings-functions: + * check-strings-patterns: + New script and correspoinding config files to help us find + untranslated strings. It's going to take some effort to make + this an easy-to-use tool. + + * components/rpmview/nautilus-rpm-view.c: + (nautilus_rpm_view_initialize): Fixed string that would not + get translated properly since it was using N_ and nothing + was going to use _() on it. + (nautilus_rpm_view_update_from_uri): Marked strings for + translation as requested in bug report 7149. + (nautilus_rpm_view_verify_files): Format tweak. + (nautilus_rpm_view_drag_data_received): Remove old dead code. + + * libnautilus-extensions/nautilus-tabs.c: (draw_tab_piece_aa): + Change to use C-style comments, not C++. + + * src/nautilus-application.c: (check_required_directories): Mark + strings for translation that we had missed before. + * src/nautilus-first-time-druid.c: Fix port string define so it + doesn't have to be repeated twice (and doesn't show up as an + "untranslated string"). + + * src/nautilus-about.c: Formatting tweak. + * src/nautilus-location-bar.c: Fix typo. + 2001-02-28 Gene Z. Ragan <gzr@eazel.com> reviewed by: Pavel Cisler <pavel@eazel.com> diff --git a/check-strings-functions b/check-strings-functions new file mode 100644 index 000000000..3867fb082 --- /dev/null +++ b/check-strings-functions @@ -0,0 +1,11 @@ +N_ +_ +fopen +g_error +g_warning +gtk_signal_connect +gtk_widget_new +gtk_window_set_wmclass +puts +setmntent +xml.+ diff --git a/check-strings-patterns b/check-strings-patterns new file mode 100644 index 000000000..474ff3faa --- /dev/null +++ b/check-strings-patterns @@ -0,0 +1,66 @@ +%s %s # common simple printf format +. ||| -skels # CORBA-generated +. ||| -stubs # CORBA-generated +\\n # common simple string +^Ali Abdin$ +^Andy Hertzfeld$ +^Arlo Rose$ +^C$ # extern "C" +^Darin Adler$ +^Eli Goldberg$ +^Elliot Lee$ +^Eskil Heyn Olsen$ +^Ettore Perazzoli$ +^Gene Z. Ragan$ +^George Lebl$ +^Ian McKellar$ +^J Shane Culpepper$ +^John Harper$ +^John Sullivan$ +^Josh Barrow$ +^Maciej Stachowiak$ +^Mathieu Lacage$ +^Mike Engber$ +^Mike Fleming$ +OAFIID # strings with oaf IIDs +^Pavel Císler$ +^Ramiro Estrugo$ +^Raph Levien$ +^Rebecca Schulman$ +^Robey Pointer$ +^Robin \* Slomkowski$ +^Seth Nickell$ +^Susan Kare$ +^\/ # paths +^[-\w/]+\.(png|xml) # recognizable file names +^bookmark$ ||| nautilus-bookmark-list +^http: +^rgb: # color specs +^Nautilus first time druid read file handle$ +^\w+\.eazel\.com$ +^[-\w]+\/[-\w\*]*$ # mime type +^Tab$ ||| druid +^\.\.?$ # self and parent in file system +network\.proxy +^_NETSCAPE_URL +^Switch to \w+ Level$ ||| nautilus-window-menus +. ||| -common\.c +^[a-z-]*help: # help URLs +^cdda: # cdda URLs +. ||| gdb3html +^0123456789ABCDEF$ +^\?+$ +^eazel-services: # eazel-services URLs +^command: # command URLs +^trash: # trash URLs +. ||| \/test # test programs +^[\d:]+$ # all numbers and colons +. ||| \/intl\/ # things in intl directory +. ||| \/po\/ # things in po directory +^\.[a-zA-Z][a-zA-Z][a-zA-Z]$ # common file extensions +^i-[-a-z]+$ # icon names +. ||| nautilus-metadata\.h # metadata keys +^\s+$ # white space only +^_SAWFISH # keys for WM +^TRUE$ +^FALSE$ diff --git a/check-strings.pl b/check-strings.pl new file mode 100755 index 000000000..4a7414795 --- /dev/null +++ b/check-strings.pl @@ -0,0 +1,173 @@ +#!/usr/bin/perl -w +# -*- Mode: perl; indent-tabs-mode: nil -*- + +# +# Nautilus +# +# Copyright (C) 2000, 2001 Eazel, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this library; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# Author: Darin Adler <darin@eazel.com>, +# + +# check-strings.pl: Search for .c and .h files where someone forgot +# to put _() around a string. + +# Throughout this file you will find extra \ before quote symbols +# that perl does not require. These are to appease emacs perl mode. + +use diagnostics; +use strict; + +# default to all the files starting from the current directory +if (!@ARGV) + { + @ARGV = `find . \\( -name '*.c' -o -name '*.h' \\) -print`; + } + +sub found_string; + +# read in file with functions for which no translation is needed +my @no_translation_needed_functions; +open FUNCTIONS, "po/check-strings-functions"; +while (<FUNCTIONS>) + { + chomp; + s/(([^\\]|\\.)*)\#.*/$1/; + s/\s*$//; + next if /^$/; + push @no_translation_needed_functions, $_; + } +close FUNCTIONS; +my $no_translation_needed_function_pattern = "^" . (join "|", @no_translation_needed_functions) . "\$"; + +# read in file with patterns for which no translation is needed +my @no_translation_needed_patterns; +open STRINGS, "check-strings-patterns"; +while (<STRINGS>) + { + chomp; + s/(([^\\]|\\.)*)\#.*/$1/; + s/\s*$//; + next if /^$/; + my ($string_pattern, $file_name_pattern) = /(.+?)\s*\|\|\|\s*(.+)/; + $string_pattern ||= $_; + $file_name_pattern ||= "."; + push @no_translation_needed_patterns, [$string_pattern, $file_name_pattern]; + } +close STRINGS; + +# look for strings that are not quoted +FILE: foreach my $file (@ARGV) + { + chomp $file; + open FILE, $file or die "can't open $file"; + + my $in_comment = 0; + + my $string = ""; + + my $last_word; + my @stack = (); + my $paren_level = 0; + my $in_exception_function = 0; + + LINE: while (<FILE>) + { + if ($in_comment) + { + s/.*?\*\/// or next LINE; + $in_comment = 0; + } + + # general approach is to just remove things we aren't interested in + + next LINE if /^\s*#\s*(\d|include)/; + + while (s/(((.*?)(\/\*|[\'\"\(\)]|\w+))|.+)//) + { + my $skipped = $3; + $skipped = $1 unless defined $skipped; + my $found = $4; + $found = "" unless defined $found; + + my $function_name = $last_word || ""; + + if ($skipped =~ /\S/ or $found =~ /^[\(\)\w]/) + { + if ($string ne "") + { + found_string ($string, $file, $.) unless $in_exception_function; + $string = ""; + } + undef $last_word; + } + + last unless $found ne ""; + + if ($found eq '"') + { + s/^(([^\\\"]|\\.)*)\"// or (print "$file:$.:unclosed quote\n"), next FILE; + $string .= $1; + } + elsif ($found eq "'") + { + s/^([^\\\']|\\.)*\'// or (print "$file:$.:unclosed single quote\n"), next FILE; + } + elsif ($found eq "/*") + { + s/^.*?\*\/// or $in_comment = 1, next LINE; + } + elsif ($found eq "(") + { + if ($function_name or $paren_level == 0) + { + push @stack, [$paren_level, $in_exception_function]; + $paren_level = 0; + $in_exception_function = 1 if $function_name =~ /$no_translation_needed_function_pattern/o; + } + $paren_level++; + } + elsif ($found eq ")") + { + (print "$file:$.:mismatched paren 1\n"), next FILE if $paren_level == 0; + $paren_level--; + if ($paren_level == 0) + { + (print "$file:$.:mismatched paren 2\n"), next FILE if @stack == 0; + ($paren_level, $in_exception_function) = @{pop @stack}; + } + } + else + { + $last_word = $found; + } + } + } + close FILE; + } + +sub found_string + { + my ($string, $file, $line) = @_; + + for my $exception (@no_translation_needed_patterns) + { + return if $string =~ /$exception->[0]/ and $file =~ /$exception->[1]/; + } + + print "$file:$line:\"$string\" is not marked for translation\n"; + } diff --git a/components/rpmview/nautilus-rpm-view.c b/components/rpmview/nautilus-rpm-view.c index 0b6df7d56..0fc38e705 100644 --- a/components/rpmview/nautilus-rpm-view.c +++ b/components/rpmview/nautilus-rpm-view.c @@ -1,7 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ /* - * Copyright (C) 2000 Eazel, Inc. + * Copyright (C) 2000, 2001 Eazel, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -62,15 +62,11 @@ #define RPM_VIEW_DEFAULT_BACKGROUND_COLOR "rgb:DDDD/DDDD/BBBB" enum { - TARGET_URI_LIST, TARGET_COLOR, - TARGET_GNOME_URI_LIST }; static GtkTargetEntry rpm_dnd_target_table[] = { - { "text/uri-list", 0, TARGET_URI_LIST }, { "application/x-color", 0, TARGET_COLOR }, - { "x-special/gnome-icon-list", 0, TARGET_GNOME_URI_LIST } }; static void nautilus_rpm_view_drag_data_received (GtkWidget *widget, @@ -347,6 +343,7 @@ nautilus_rpm_view_initialize (NautilusRPMView *rpm_view) gtk_widget_show (temp_widget); /* use a tree list now */ + list_headers[0] = _(list_headers[0]); rpm_view->details->package_file_tree = nautilus_ctree_new_with_titles (1, 0, list_headers); gtk_container_add (GTK_CONTAINER (temp_widget), rpm_view->details->package_file_tree); gtk_signal_connect (GTK_OBJECT (rpm_view->details->package_file_tree), @@ -615,9 +612,11 @@ nautilus_rpm_view_update_from_uri (NautilusRPMView *rpm_view, const char *uri) /* set up the install message and buttons */ if (is_installed) { - gtk_label_set_text (GTK_LABEL(rpm_view->details->package_installed_message), "This package is currently installed"); + gtk_label_set_text (GTK_LABEL(rpm_view->details->package_installed_message), + _("This package is currently installed")); } else { - gtk_label_set_text (GTK_LABEL(rpm_view->details->package_installed_message), "This package is currently not installed"); + gtk_label_set_text (GTK_LABEL(rpm_view->details->package_installed_message), + _("This package is currently not installed")); } if (is_installed == 0) { @@ -759,7 +758,8 @@ nautilus_rpm_view_verify_files (GtkWidget *widget, if (rpm_view->details->verify_success) { nautilus_rpm_verify_window_set_error_mode (NAUTILUS_RPM_VERIFY_WINDOW (rpm_view->details->verify_window), FALSE); - nautilus_rpm_verify_window_set_message (NAUTILUS_RPM_VERIFY_WINDOW (rpm_view->details->verify_window), _("Verification completed, package ok.")); + nautilus_rpm_verify_window_set_message (NAUTILUS_RPM_VERIFY_WINDOW (rpm_view->details->verify_window), + _("Verification completed, package ok.")); } else { } } @@ -782,12 +782,6 @@ nautilus_rpm_view_drag_data_received (GtkWidget *widget, GdkDragContext *context g_return_if_fail (NAUTILUS_IS_RPM_VIEW (widget)); switch (info) { - case TARGET_GNOME_URI_LIST: - case TARGET_URI_LIST: - g_message ("dropped data on rpm_view: %s", selection_data->data); - break; - - case TARGET_COLOR: /* Let the background change based on the dropped color. */ nautilus_background_receive_dropped_color (nautilus_get_widget_background (widget), diff --git a/libnautilus-extensions/nautilus-tabs.c b/libnautilus-extensions/nautilus-tabs.c index 6f12f14e9..2fa4c7467 100644 --- a/libnautilus-extensions/nautilus-tabs.c +++ b/libnautilus-extensions/nautilus-tabs.c @@ -370,7 +370,7 @@ draw_tab_piece_aa (NautilusTabs *tabs, GdkPixbuf *dest_pixbuf, int x, int y, int widget = GTK_WIDGET (tabs); pixbuf = tabs->details->tab_piece_images[which_piece]; - // if there's no pixbuf, just exit, returning a nominal size + /* if there's no pixbuf, just exit, returning a nominal size */ if (pixbuf == NULL) { return 32; } @@ -380,7 +380,7 @@ draw_tab_piece_aa (NautilusTabs *tabs, GdkPixbuf *dest_pixbuf, int x, int y, int dest_width = gdk_pixbuf_get_width (dest_pixbuf); dest_height = gdk_pixbuf_get_height (dest_pixbuf); - // trim tab piece to fit within the destination and the passed in limits + /* trim tab piece to fit within the destination and the passed in limits */ if (x_limit > 0) { if (x_limit < dest_width) { diff --git a/libnautilus-private/nautilus-tabs.c b/libnautilus-private/nautilus-tabs.c index 6f12f14e9..2fa4c7467 100644 --- a/libnautilus-private/nautilus-tabs.c +++ b/libnautilus-private/nautilus-tabs.c @@ -370,7 +370,7 @@ draw_tab_piece_aa (NautilusTabs *tabs, GdkPixbuf *dest_pixbuf, int x, int y, int widget = GTK_WIDGET (tabs); pixbuf = tabs->details->tab_piece_images[which_piece]; - // if there's no pixbuf, just exit, returning a nominal size + /* if there's no pixbuf, just exit, returning a nominal size */ if (pixbuf == NULL) { return 32; } @@ -380,7 +380,7 @@ draw_tab_piece_aa (NautilusTabs *tabs, GdkPixbuf *dest_pixbuf, int x, int y, int dest_width = gdk_pixbuf_get_width (dest_pixbuf); dest_height = gdk_pixbuf_get_height (dest_pixbuf); - // trim tab piece to fit within the destination and the passed in limits + /* trim tab piece to fit within the destination and the passed in limits */ if (x_limit > 0) { if (x_limit < dest_width) { diff --git a/src/nautilus-about.c b/src/nautilus-about.c index 79e484ebe..c57f8ae68 100644 --- a/src/nautilus-about.c +++ b/src/nautilus-about.c @@ -199,7 +199,7 @@ nautilus_about_new (const char *title, /* draw the info onto the pixbuf, once and for all */ nautilus_about_draw_info (about, title, version, copyright, - authors, comments, translators, time_stamp); + authors, comments, translators, time_stamp); return GTK_WIDGET (about); } diff --git a/src/nautilus-application.c b/src/nautilus-application.c index 10d0098ff..4698b1407 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -272,15 +272,17 @@ check_required_directories (NautilusApplication *application) if (failed_count == 1) { dialog_title = g_strdup (_("Couldn't Create Required Folder")); - error_string = g_strdup_printf ("Nautilus could not create the required folder \"%s\". " - "Before running Nautilus, please create this folder, or " - "set permissions such that Nautilus can create it.", dir_list_concatenated); + error_string = g_strdup_printf (_("Nautilus could not create the required folder \"%s\". " + "Before running Nautilus, please create this folder, or " + "set permissions such that Nautilus can create it."), + dir_list_concatenated); } else { dialog_title = g_strdup (_("Couldn't Create Required Folders")); - error_string = g_strdup_printf ("Nautilus could not create the following required folders:\n\n" - "%s\n\n" - "Before running Nautilus, please create these folders, or " - "set permissions such that Nautilus can create them.", dir_list_concatenated); + error_string = g_strdup_printf (_("Nautilus could not create the following required folders:\n\n" + "%s\n\n" + "Before running Nautilus, please create these folders, or " + "set permissions such that Nautilus can create them."), + dir_list_concatenated); } dialog = nautilus_show_error_dialog (error_string, dialog_title, NULL); diff --git a/src/nautilus-first-time-druid.c b/src/nautilus-first-time-druid.c index c46aa29fe..bda6d58b6 100644 --- a/src/nautilus-first-time-druid.c +++ b/src/nautilus-first-time-druid.c @@ -75,7 +75,7 @@ enum { /* Preference for http proxy settings */ #define DEFAULT_HTTP_PROXY_PORT 8080 -#define DEFAULT_HTTP_PROXY_PORT_STRING "8080" +#define DEFAULT_HTTP_PROXY_PORT_STRING #DEFAULT_HTTP_PROXY_PORT #define GNOME_VFS_PREFERENCES_HTTP_PROXY_HOST "/system/gnome-vfs/http-proxy-host" #define GNOME_VFS_PREFERENCES_HTTP_PROXY_PORT "/system/gnome-vfs/http-proxy-port" #define GNOME_VFS_PREFERENCES_USE_HTTP_PROXY "/system/gnome-vfs/use-http-proxy" diff --git a/src/nautilus-location-bar.c b/src/nautilus-location-bar.c index 5f14f1419..ddc709c73 100644 --- a/src/nautilus-location-bar.c +++ b/src/nautilus-location-bar.c @@ -668,7 +668,7 @@ nautilus_location_bar_set_location (NautilusNavigationBar *navigation_bar, * * returns a newly allocated "string" containing the mangled * (by nautilus_make_uri_from_input) text that the user typed in...maybe a URI - * but not garunteed. + * but not guaranteed. * **/ static char * |