You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Erik Huelsmann <e....@gmx.net> on 2004/04/25 21:42:53 UTC

Translation problems with string constants

There are several cases in which string constants stand in the way of easy
translation. The first being parametrised strings; I'd like to solve those
this way:

   SVN_ERRDEF (SVN_ERR_CLIENT_REVISION_AUTHOR_CONTAINS_NEWLINE,
               SVN_ERR_CLIENT_CATEGORY_START + 10,
-              SVN_PROP_REVISION_AUTHOR " contains a newline")
+              N_("svn:author contains a newline"))
+

Anybody who deems this unacceptable?


An other being the format strings like SVN_REVNUM_T_FMT; those can be solved
by introducing functions which do the revnum -> string formatting and having
the SVN_REVNUM_T_FMT (and friends) replaced with %s.
There are two possible solutions to stringify the information:
1) Add macros 
2) Add (inline) functions

In both cases the question is: where?

My preferance would be (public) macros because they do not require linking
any specific library.

bye,

Erik.

-- 
"Sie haben neue Mails!" - Die GMX Toolbar informiert Sie beim Surfen!
Jetzt aktivieren unter http://www.gmx.net/info


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Translation problems with string constants

Posted by Greg Hudson <gh...@MIT.EDU>.
On Sun, 2004-04-25 at 17:42, Erik Huelsmann wrote:
> My preferance would be (public) macros because they do not require linking
> any specific library.

Macros are fine with me if (and only if) they don't expose internal bits
of the ABI.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Translation problems with string constants

Posted by kf...@collab.net.
"Erik Huelsmann" <e....@gmx.net> writes:
> > Why not?  The static initializer is just a string constant; it can be
> > substituted into another string with %s, no?
> 
> yea, but this particular case was in the error messages table. There are two
> or three more cases like this one. In tables like those it's hard to use the
> trick, since the general error messages do not take arguments.

Oh, right.  Oy.  We'd have to add an svn_initialize() or something, to
set up a bunch of global variables holding the error strings.  Hmmm.

I'm loathe to hardcode "svn:author" instead of using the #define.  But
I don't see a reasonable alternative here :-(.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Translation problems with string constants

Posted by Erik Huelsmann <e....@gmx.net>.
> "Erik Huelsmann" <e....@gmx.net> writes:
> > The case demonstrated above is a static initializer though so that this
> > scheme does not apply.
> 
> Why not?  The static initializer is just a string constant; it can be
> substituted into another string with %s, no?

yea, but this particular case was in the error messages table. There are two
or three more cases like this one. In tables like those it's hard to use the
trick, since the general error messages do not take arguments.


Erik.

-- 
"Sie haben neue Mails!" - Die GMX Toolbar informiert Sie beim Surfen!
Jetzt aktivieren unter http://www.gmx.net/info


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Translation problems with string constants

Posted by kf...@collab.net.
"Erik Huelsmann" <e....@gmx.net> writes:
> The case demonstrated above is a static initializer though so that this
> scheme does not apply.

Why not?  The static initializer is just a string constant; it can be
substituted into another string with %s, no?


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Translation problems with string constants

Posted by Erik Huelsmann <e....@gmx.net>.
> "Erik Huelsmann" <e....@gmx.net> writes:
> > There are several cases in which string constants stand in the way of
> easy
> > translation. The first being parametrised strings; I'd like to solve
> those
> > this way:
> > 
> >    SVN_ERRDEF (SVN_ERR_CLIENT_REVISION_AUTHOR_CONTAINS_NEWLINE,
> >                SVN_ERR_CLIENT_CATEGORY_START + 10,
> > -              SVN_PROP_REVISION_AUTHOR " contains a newline")
> > +              N_("svn:author contains a newline"))
> > +
> > 
> 
> Is there some way to generalize the SVN_REVNUM_T_FMT solution so it
> can be used for generic strings like SVN_PROP_REVISION_AUTHOR as well?

Yes, in general it is possible to use apr_psprintf() to transform numbers to
strings using the SVN_REVNUM_T_FMT format string and use that string for a
%s format specifier in the destination string. 

An example:

   SVN_ERR_W( ... some code ... ,
              apr_psprintf("Error committing r" SVN_REVNUM_T_FMT "\n",
                           revision, pool));

becomes:

   SVN_ERR_W( ... some code ... ,
              apr_psprintf("Error committing r%s\n",
                           SVN_REV_TO_STR(revision, pool)));

where:

#define SVN_REV_TO_STR(rev, pool) apr_psprintf(SVN_REVNUM_T_FMT, rev, pool)



The case demonstrated above is a static initializer though so that this
scheme does not apply.

bye,

Erik.



-- 
"Sie haben neue Mails!" - Die GMX Toolbar informiert Sie beim Surfen!
Jetzt aktivieren unter http://www.gmx.net/info


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Translation problems with string constants

Posted by kf...@collab.net.
"Erik Huelsmann" <e....@gmx.net> writes:
> There are several cases in which string constants stand in the way of easy
> translation. The first being parametrised strings; I'd like to solve those
> this way:
> 
>    SVN_ERRDEF (SVN_ERR_CLIENT_REVISION_AUTHOR_CONTAINS_NEWLINE,
>                SVN_ERR_CLIENT_CATEGORY_START + 10,
> -              SVN_PROP_REVISION_AUTHOR " contains a newline")
> +              N_("svn:author contains a newline"))
> +
> 
> Anybody who deems this unacceptable?
> 
> 
> An other being the format strings like SVN_REVNUM_T_FMT; those can be solved
> by introducing functions which do the revnum -> string formatting and having
> the SVN_REVNUM_T_FMT (and friends) replaced with %s.
> There are two possible solutions to stringify the information:
> 1) Add macros 
> 2) Add (inline) functions
> 
> In both cases the question is: where?

Is there some way to generalize the SVN_REVNUM_T_FMT solution so it
can be used for generic strings like SVN_PROP_REVISION_AUTHOR as well?

As far as where, I think (sigh) libsvn_subr is probably the place,
unless...

> My preferance would be (public) macros because they do not require linking
> any specific library.

... unless you can do it with macros :-), in which case svn_types.h
might be the place?  (svn_subst.h is tempting, but it's really about
Subversion doing substitutions on user data, not Subversion developers
doing substitutions on Subversion's own code.)

-Karl

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org