r19077 - gnucash/trunk - Bug #616696 - Development version warning string should not include hardcode version.

Geert Janssens janssens-geert at telenet.be
Wed Apr 28 09:31:18 EDT 2010


On Tuesday 27 April 2010, Christian Stimming wrote:
> Am Dienstag, 27. April 2010 schrieb Geert Janssens:
> > Ugh, I had this gut feeling something wasn't right...
> >
> > I've quickly looked at the code, but I don't think it's easy to modify it
> >  in such a way that parameters can be substituted generically. I could
> > add some exception code that particularly tests for my use case
> > (GNUCASH_LATEST_STABLE_VERSION), but I don't like that idea.
> 
> I thought of changing the string so that it contains %s instead of @-
> GNUCASH_LATEST_STABLE_VERSION-@:
> 
>   "...use the latest release of GnuCash %s.")
> 
> This string would be the only tip-of-day that contains a "%s". So you would
> then also modify the tip-of-day display code to check for this single
> exception. All other strings are just translated, but this one after
> translation would be passed through sprintf as well.
> 
> > Unless someone knows a better way to implement this, I'll just revert my
> > change altogether.
> 
> Well, yes, unless you are up to try out the workaround described above :-)
> 
> Thanks for picking up the issue, tho :-)
> 
> Regards,
> 
> Christian
> 
Ok, I have reworked my solution yet again (learning lots along the way).

Tips now can have string substitutions (%s). The way to set it up is
_("Tip text with %s and another %s")|value1|value2

So replacement values can be added at the end of the tip (outside the gettext-
parsed block), separated with | characters.
The motd code will split the tip into its components, use the first component 
as format string that will be passed to gettext for translation. The other 
components will be inserted into the string after translation.

This makes "|" an illegal character for future tips as it would mess up the 
parsing.

You can have as much substitutions as you like, but only string substitutions 
will work. I think you will get unexpected results if you try to add other 
substitutions like %d.

Geert


More information about the gnucash-devel mailing list