Christopher Allan Webber <[email protected]> writes:
> I've been thinking about what I'm going to do once I hit the need for
> gettext support. I'm not really sure for things that have multiple
> variables in their string. In python land, I'd do something like:
>
> gettext("foo %(bar) %(baz)") % {"bar": "bleh",
> "baz": "wonk"}
>
> This would give translators an opportunity to move the right parameters
> to the right place in the string. However, this appears to not be
> possible in our current format system, because there's no place to put
> keyword based substitutable arguments. Syntactic word ordering varies
> from natural language to natural language, so...
It's true that (ice-9 format) doesn't provide a way to specify
substitutable arguments by keyword, but it _does_ provide a way to
specify arguments by index. Search for "Argument jumping" in section
7.10 (Formatted Output) of the Guile manual. In particular, "~0@*" sets
the argument "pointer" to the first argument (index 0), and more
generally "~N@*" jumps to argument N. So, for example:
scheme@(guile-user)> (format #f "~0@*~d and ~1@*~d" 1 2)
$1 = "1 and 2"
scheme@(guile-user)> (format #f "~1@*~d and ~0@*~d" 1 2)
$2 = "2 and 1"
I agree that this is not very nice, and that we should find a better
solution.
Mark