an i18n sample

Eli Zaretskii eliz@gnu.org
Sun Oct 24 19:28:00 GMT 2004


> Date: Sun, 24 Oct 2004 12:48:05 +0200
> From: Baurjan Ismagulov <ibr@ata.cs.hun.edu.tr>
> 
> I've begun to mark up translatable strings in gdb/. I thought it would
> be easier to review if I do it in small chunks; please inform me if you
> prefer one big file.

Smaller chunks are better, IMHO.  But please wait for others to
respond, perhaps I'm the minority.

> What do you think?

Thanks.

In general, the changes are okay, but I have a few comments:

>  is_nondebugging_type (struct type *type)
>  {
>    char *name = ada_type_name (type);
> -  return (name != NULL && strcmp (name, "<variable, no debug info>") == 0);
> +  return (name != NULL && strcmp (name, _("<variable, no debug info>")) == 0);

Where is the text "<variable, no debug info>" coming from?  If it is
not translated where it is produced, then you should compare with the
literal untranslated string here.

> -          fprintf_unfiltered (gdb_stderr, "Type ");
> +          fprintf_unfiltered (gdb_stderr, _("Type "));
>            if (type == NULL)
> -            fprintf_unfiltered (gdb_stderr, "(null)");
> +            fprintf_unfiltered (gdb_stderr, _("(null)"));
>            else
>              type_print (type, "", gdb_stderr, -1);
> -          error (" is not a structure or union type");
> +          error (_(" is not a structure or union type"));

This fragment should be rewritten to use full sentences, like in
"Type (null) is not a structure or union type", instead of marking
each part separately.  That way, a translator will be able to
translate the entire sentence as a single entity, rather than each
part.  (Translating sentences in parts usually leads to bad
translations, unless the translator makes an effort to read the
source.)

> @@ -5664,10 +5664,10 @@ BadName:
>      {
>        target_terminal_ours ();
>        gdb_flush (gdb_stdout);
> -      fprintf_unfiltered (gdb_stderr, "Type ");
> +      fprintf_unfiltered (gdb_stderr, _("Type "));
>        type_print (type, "", gdb_stderr, -1);
> -      fprintf_unfiltered (gdb_stderr, " has no component named ");
> -      error ("%s", name == NULL ? "<null>" : name);
> +      fprintf_unfiltered (gdb_stderr, _(" has no component named "));
> +      error ("%s", name == NULL ? _("<null>") : name);
>      }

Same here.

> @@ -6005,7 +6005,7 @@ empty_record (struct objfile *objfile)
>    TYPE_CODE (type) = TYPE_CODE_STRUCT;
>    TYPE_NFIELDS (type) = 0;
>    TYPE_FIELDS (type) = NULL;
> -  TYPE_NAME (type) = "<empty>";
> +  TYPE_NAME (type) = _("<empty>");
>    TYPE_TAG_NAME (type) = NULL;
>    TYPE_FLAGS (type) = 0;
>    TYPE_LENGTH (type) = 0;
> @@ -6167,8 +6167,8 @@ ada_template_to_fixed_record_type_1 (str
>       the current RTYPE length might be good enough for our purposes.  */
>    if (TYPE_LENGTH (type) <= 0)
>      {
> -      warning ("Invalid type size for `%s' detected: %d.",
> -               TYPE_NAME (rtype) ? TYPE_NAME (rtype) : "<unnamed>",
> +      warning (_("Invalid type size for `%s' detected: %d."),
> +               TYPE_NAME (rtype) ? TYPE_NAME (rtype) : _("<unnamed>"),
>                 TYPE_LENGTH (type));
>      }

Same here.

>      case UNOP_IN_RANGE:
>      case UNOP_QUAL:
> -      fprintf_filtered (stream, "Type @");
> +      fprintf_filtered (stream, _("Type @"));
>        gdb_print_host_address (exp->elts[pc + 1].type, stream);
>        fprintf_filtered (stream, " (");
>        type_print (exp->elts[pc + 1].type, NULL, stream, 0);

Same here.

> @@ -8361,9 +8361,9 @@ ada_print_subexp (struct expression *exp
>      case BINOP_IN_BOUNDS:
>        *pos += oplen;
>        print_subexp (exp, pos, stream, PREC_SUFFIX);
> -      fputs_filtered (" in ", stream);
> +      fputs_filtered (_(" in "), stream);
>        print_subexp (exp, pos, stream, PREC_SUFFIX);
> -      fputs_filtered ("'range", stream);
> +      fputs_filtered (_("'range"), stream);
>        if (exp->elts[pc + 1].longconst > 1)
>          fprintf_filtered (stream, "(%ld)",
>                            (long) exp->elts[pc + 1].longconst);

Same here.

> @@ -8374,7 +8374,7 @@ ada_print_subexp (struct expression *exp
>        if (prec >= PREC_EQUAL)
>          fputs_filtered ("(", stream);
>        print_subexp (exp, pos, stream, PREC_SUFFIX);
> -      fputs_filtered (" in ", stream);
> +      fputs_filtered (_(" in "), stream);
>        print_subexp (exp, pos, stream, PREC_EQUAL);
>        fputs_filtered (" .. ", stream);
>        print_subexp (exp, pos, stream, PREC_EQUAL);

Same here.

> @@ -8426,7 +8426,7 @@ ada_print_subexp (struct expression *exp
>      case UNOP_IN_RANGE:
>        *pos += oplen;
>        print_subexp (exp, pos, stream, PREC_SUFFIX);
> -      fputs_filtered (" in ", stream);
> +      fputs_filtered (_(" in "), stream);
>        LA_PRINT_TYPE (exp->elts[pc + 1].type, "", stream, 1, 0);
>        return;
>      }

Same here.

> @@ -537,12 +537,12 @@ print_variant_clauses (struct type *type
>  
>    for (i = 0; i < TYPE_NFIELDS (var_type); i += 1)
>      {
> -      fprintf_filtered (stream, "\n%*swhen ", level + 4, "");
> +      fprintf_filtered (stream, _("\n%*swhen "), level + 4, "");
>        print_choices (var_type, i, stream, discr_type);
>        fprintf_filtered (stream, " =>");
>        if (print_record_field_types (TYPE_FIELD_TYPE (var_type, i),
>  				    outer_type, stream, show, level + 4) <= 0)
> -	fprintf_filtered (stream, " null;");
> +	fprintf_filtered (stream, _(" null;"));
>      }

This also, and in addition I think it plays character-counting games
that are no-no in translatable messages.

> @@ -558,12 +558,12 @@ static void
>  print_variant_part (struct type *type, int field_num, struct type *outer_type,
>  		    struct ui_file *stream, int show, int level)
>  {
> -  fprintf_filtered (stream, "\n%*scase %s is", level + 4, "",
> +  fprintf_filtered (stream, _("\n%*scase %s is"), level + 4, "",
>  		    ada_variant_discrim_name
>  		    (TYPE_FIELD_TYPE (type, field_num)));
>    print_variant_clauses (type, field_num, outer_type, stream, show,
>  			 level + 4);
> -  fprintf_filtered (stream, "\n%*send case;", level + 4, "");
> +  fprintf_filtered (stream, _("\n%*send case;"), level + 4, "");
>  }

Ditto.

>  /* Print a description on STREAM of the fields in record type TYPE, whose
> @@ -632,15 +632,15 @@ print_record_type (struct type *type0, s
>  
>    parent_type = ada_parent_type (type);
>    if (ada_type_name (parent_type) != NULL)
> -    fprintf_filtered (stream, "new %s with ",
> +    fprintf_filtered (stream, _("new %s with "),
>  		      decoded_type_name (parent_type));
>    else if (parent_type == NULL && ada_is_tagged_type (type, 0))
> -    fprintf_filtered (stream, "tagged ");
> +    fprintf_filtered (stream, _("tagged "));
>  
> -  fprintf_filtered (stream, "record");
> +  fprintf_filtered (stream, _("record"));
>  
>    if (show < 0)
> -    fprintf_filtered (stream, " ... end record");
> +    fprintf_filtered (stream, _(" ... end record"));
>    else
>      {
>        int flds;
> @@ -652,11 +652,11 @@ print_record_type (struct type *type0, s
>        flds += print_record_field_types (type, type, stream, show, level);
>  
>        if (flds > 0)
> -	fprintf_filtered (stream, "\n%*send record", level, "");
> +	fprintf_filtered (stream, _("\n%*send record"), level, "");
>        else if (flds < 0)
> -	fprintf_filtered (stream, " <incomplete type> end record");
> +	fprintf_filtered (stream, _(" <incomplete type> end record"));
>        else
> -	fprintf_filtered (stream, " null; end record");
> +	fprintf_filtered (stream, _(" null; end record"));
>      }
>  }

Same here.

> @@ -668,21 +668,21 @@ static void
>  print_unchecked_union_type (struct type *type, struct ui_file *stream,
>  			    int show, int level)
>  {
> -  fprintf_filtered (stream, "record (?) is");
> +  fprintf_filtered (stream, _("record (?) is"));
>  
>    if (show < 0)
> -    fprintf_filtered (stream, " ... end record");
> +    fprintf_filtered (stream, _(" ... end record"));
>    else if (TYPE_NFIELDS (type) == 0)
> -    fprintf_filtered (stream, " null; end record");
> +    fprintf_filtered (stream, _(" null; end record"));
>    else
>      {
>        int i;
>  
> -      fprintf_filtered (stream, "\n%*scase ? is", level + 4, "");
> +      fprintf_filtered (stream, _("\n%*scase ? is"), level + 4, "");
>  
>        for (i = 0; i < TYPE_NFIELDS (type); i += 1)
>  	{
> -	  fprintf_filtered (stream, "\n%*swhen ? =>\n%*s", level + 8, "",
> +	  fprintf_filtered (stream, _("\n%*swhen ? =>\n%*s"), level + 8, "",
>  			    level + 12, "");
>  	  ada_print_type (TYPE_FIELD_TYPE (type, i),
>  			  TYPE_FIELD_NAME (type, i),
> @@ -690,7 +690,7 @@ print_unchecked_union_type (struct type 
>  	  fprintf_filtered (stream, ";");
>  	}
>  
> -      fprintf_filtered (stream, "\n%*send case;\n%*send record",
> +      fprintf_filtered (stream, _("\n%*send case;\n%*send record"),
>  			level + 4, "", level, "");
>      }
>  }
> @@ -706,9 +706,9 @@ print_func_type (struct type *type, stru
>    int i, len = TYPE_NFIELDS (type);
>  
>    if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID)
> -    fprintf_filtered (stream, "procedure");
> +    fprintf_filtered (stream, _("procedure"));
>    else
> -    fprintf_filtered (stream, "function");
> +    fprintf_filtered (stream, _("function"));
>  
>    if (name != NULL && name[0] != '\0')
>      fprintf_filtered (stream, " %s", name);
> @@ -731,7 +731,7 @@ print_func_type (struct type *type, stru
>  
>    if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
>      {
> -      fprintf_filtered (stream, " return ");
> +      fprintf_filtered (stream, _(" return "));
>        ada_print_type (TYPE_TARGET_TYPE (type), "", stream, 0, 0);
>      }
>  }
> @@ -763,7 +763,7 @@ ada_print_type (struct type *type0, char
>        if (is_var_decl)
>  	fprintf_filtered (stream, "%.*s: ",
>  			  ada_name_prefix_len (varstring), varstring);
> -      fprintf_filtered (stream, "<null type?>");
> +      fprintf_filtered (stream, _("<null type?>"));
>        return;
>      }
>  
> @@ -794,11 +794,11 @@ ada_print_type (struct type *type0, char
>  	fprintf_filtered (stream, ">");
>  	break;
>        case TYPE_CODE_PTR:
> -	fprintf_filtered (stream, "access ");
> +	fprintf_filtered (stream, _("access "));
>  	ada_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
>  	break;
>        case TYPE_CODE_REF:
> -	fprintf_filtered (stream, "<ref> ");
> +	fprintf_filtered (stream, _("<ref> "));
>  	ada_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
>  	break;
>        case TYPE_CODE_ARRAY:
> @@ -813,11 +813,11 @@ ada_print_type (struct type *type0, char
>  	  {
>  	    char *name = ada_type_name (type);
>  	    if (!ada_is_range_type_name (name))
> -	      fprintf_filtered (stream, "<%d-byte integer>",
> +	      fprintf_filtered (stream, _("<%d-byte integer>"),
>  				TYPE_LENGTH (type));
>  	    else
>  	      {
> -		fprintf_filtered (stream, "range ");
> +		fprintf_filtered (stream, _("range "));
>  		print_range_type_named (name, stream);
>  	      }
>  	  }

Same here.



More information about the Gdb-patches mailing list