As you wrote in the FAQ, printfwill not reorder arguments as in the example of fmt: fmt::format("{0}{1}{0}", "abra", "cad"); but wouldn't it be possible to create a wrapper function that looks up a translation from the format string and rearranges the parameters before calling printf? This would allow use to create binaries that contains only the literals for a specific language and still supports a usage like gettext.
Example:
printtext( "{1} beer to {0} guests.", 4, 2 );
could lookup the translation of "{1} beer to {0} guests." to the target language, check the arguments and then generate a function that rearranges the arguments when calling printf.
As you wrote in the FAQ,
printf
will not reorder arguments as in the example offmt: fmt::format("{0}{1}{0}", "abra", "cad");
but wouldn't it be possible to create a wrapper function that looks up a translation from the format string and rearranges the parameters before callingprintf
? This would allow use to create binaries that contains only the literals for a specific language and still supports a usage likegettext
.Example:
printtext( "{1} beer to {0} guests.", 4, 2 );
could lookup the translation of
"{1} beer to {0} guests."
to the target language, check the arguments and then generate a function that rearranges the arguments when calling printf.