[Spice-devel] [PATCH 12/22] Add exception handling classes
Christophe Fergeau
cfergeau at redhat.com
Wed Mar 28 15:04:31 UTC 2018
On Wed, Mar 28, 2018 at 02:44:56PM +0200, Christophe de Dinechin wrote:
> In my proposal, that message is built in format_message with something like:
>
> int written = snprintf(buffer, size, "%s writing %s for file ‘%s'", what(), operation, filename.c_str());
> return append_strerror(buffer, size, written);
>
> It would be better to instead generate “L’écriture du format a été
> interrompue pour le fichier ‘Hello.txt’”; which involves word
> reordering and grammatical pairing (e.g. contractions, male/female,
> etc). In order to do that, you can take a more subtle approach where
> instead of translating pieces individually, you translate the complete
> message, but still carefully ignore the parts that you know are
> variable. So you could do instead:
>
> snprintf(translated, sizeof(translated), “%s writing %s for file ‘%%s’”, what(), operation);
> int written = snprintf(buffer, size, _(translated), filename.c_str());
> return append_strerror(buffer, size, written);
>
> In that case, obviously, you need to provide more translations:
> - “write failed writing header for file ‘%s'” -> “l’écriture de l’en-tête du fichier ‘%s’ a échoué"
> - “write failed writing frame for file ‘%s'” -> “l’écriture d’une image du fichier ‘%s' a échoué"
> - “write interrupted writing frame for file ‘%s'” -> “l’écriture d’une image du fichier ‘%s’ a été interrompue”
> … etc
>
> What matters, however, is that you still have a finite number of
> combinations, because you have a finite number of input strings.
The part I'm missing is how you extract this limited number of full
strings that we'll need to translate into a po file (or equivalent). Is
there a tool which will generate that list of strings from %s writing
%s for file ... and the static strings which are passed as %s arguments to
snprintf?
> >> WriteError(“can’t write header” + filename)
> >>
> >> it suddenly becomes impossible to do localization?
> >
> > so WriteError("can't write header" + filename) is actually *better* from
> > a translation point of view, as you'd mark "can't write header" for
> > translation and be done with it.
>
> This would not work in German, where you’d want to have the file name somewhere in the middle, as in “Beim Schreiben der Kopfzeile für die Datei ‘Hello.txt' ist ein Fehler aufgetreten”…
My bad, I read your example too quickly and assumed you wrote
"can't write header: " + filename, in other words that the filename was
totally separate from the sentence. I was indeed not suggesting you can
create a valid sentence by appending it to the end...
This is easily worked around with a snprintf, or with boost::format
though if we wanted to do the localization there..
> and your “better” argument, which was already slashed in microscopic
> fragments by the German counter example, becomes all the more
> difficult to reassemble.
This is not really helping the conversation to move smoothly...
> Christophe Christophe Christophe Christophe (since I have to repeat myself quite a lot, I thought I’d do it in the signature too ;-)
I'm fine with a link to the mailing list archives when I'm asking
questions about something you've already explained, but which I missed..
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180328/56216a94/attachment.sig>
More information about the Spice-devel
mailing list