[haiku-development] Re: Patch reviews - help needed
- From: Michael Pfeiffer <michael.w.pfeiffer@xxxxxxxxx>
- To: haiku-development@xxxxxxxxxxxxx
- Date: Thu, 6 May 2010 17:23:01 +0200
Am 06.05.2010 um 16:08 schrieb Stephan Assmus:
> * The patch should ideally remove string composition:
>
> BString errorString;
> errorString << "The file '";
> errorString fileName;
> errorString << "' cannot be found.";
>
> should become:
>
> char buffer[512];
> snprintf(buffer, sizeof(buffer), TR("The file '%s' cannot be "
> "found."), fileName);
>
For this case I prefer this solution:
BString buffer(TR("The file '%file' cannot be found."));
buffer.ReplaceFirst("%file", fileName);
Because then you don't have to worry about the size of the buffer
and in case there is more than one substitution variable their
order can be defined by the translator.
For example:
BString buffer(TR("%length %unit"));
buffer.ReplaceFirst("%length", "42");
buffer.ReplaceFirst("%unit", "mm");
In the translation it could be "%unit %length", I admit that is not
a good example.
- Michael
- Follow-Ups:
- [haiku-development] Re: Patch reviews - help needed
- From: Stephan Assmus
- [haiku-development] Re: Patch reviews - help needed
- References:
- [haiku-development] Patch reviews - help needed
- From: Stephan Assmus
- [haiku-development] Re: Patch reviews - help needed
- From: Alexandre Deckner
- [haiku-development] Re: Patch reviews - help needed
- From: Ingo Weinhold
- [haiku-development] Re: Patch reviews - help needed
- From: Stephan Assmus
- [haiku-development] Re: Patch reviews - help needed
- From: Rene Gollent
- [haiku-development] Re: Patch reviews - help needed
- From: Stephan Assmus
- [haiku-development] Patch reviews - help needed
Other related posts:
- » [haiku-development] Patch reviews - help needed - Stephan Assmus
- » [haiku-development] Re: Patch reviews - help needed - Alexandre Deckner
- » [haiku-development] Re: Patch reviews - help needed - Adrien Destugues
- » [haiku-development] Re: Patch reviews - help needed - Ithamar R. Adema
- » [haiku-development] Re: Patch reviews - help needed - Stephan Assmus
- » [haiku-development] Re: Patch reviews - help needed - Ingo Weinhold
- » [haiku-development] Re: Patch reviews - help needed - David McPaul
- » [haiku-development] Re: Patch reviews - help needed - Stephan Assmus
- » [haiku-development] Re: Patch reviews - help needed - Rene Gollent
- » [haiku-development] Re: Patch reviews - help needed - Niels Reedijk
- » [haiku-development] Re: Patch reviews - help needed - Matt Madia
- » [haiku-development] Re: Patch reviews - help needed - Stephan Assmus
- » [haiku-development] Re: Patch reviews - help needed - Michael Pfeiffer
- » [haiku-development] Re: Patch reviews - help needed - Stephan Assmus