monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] Incorrect use of numbered format specifiers (opinionate


From: Zack Weinberg
Subject: [Monotone-devel] Incorrect use of numbered format specifiers (opinionated rant)
Date: Mon, 31 Jul 2006 01:12:42 -0700

In revision d5c243284c11d56d314180296b17666a8ee221a7, numbered format
specifiers appear in cmd_ws_commit.cc:

       * cmd_ws_commit.cc (CMD(commit)): Use positional format
       to ease translation.
--- cmd_ws_commit.cc    f24529cd245deb0002fdaa15f0f8b6d1e9d0e338
+++ cmd_ws_commit.cc    7ea434328406ac23a1afea4262b08bb9ec25d500
@@ -771,7 +771,7 @@ CMD(commit, N_("workspace"), N_("[PATH].
              // If we don't err out here, our packet writer will
              // later.
              E(false,
-                F("Your database is missing version %s of file '%s'")
+                F("Your database is missing version %1% of file '%2%'")
                % old_content % path);
          }

Numbered format specifiers should never appear in the source code,
because it's confusing (most of us have to stop and scratch our heads
to remember what they do), confusing (when reading the source code, we
want to be *sure* that the specifiers are in the same order as the
arguments they consume, and with numbered specifiers, they aren't
necessarily), and confusing (the weird boost-specific %1% notation
does not tell you *how* the argument will be printed).

Remember that numbered specifiers are for translation.  It is possible
that the most fluent way to phrase the sentence "Your database is
missing version X of file Y" in some language requires that Y come
before X.  Numbered specifiers, then, should appear ONLY in .po files
for languages that need them, and ONLY for the sentences that need
them.  It is perfectly fine for a po file to have numbered specifiers
in the msgstr and not the msgid, like so:

msgid "Your database is missing version %s of file '%s'"
msgstr "File '%2$s', version '%1$s', is missing from your database"

Furthermore, I urge people to use only the standard (SuSv3) %1$s, %2$s
notation rather than the aforementioned weird boost-specific notation
that leaves out the "how this will be formatted" letter.

zw




reply via email to

[Prev in Thread] Current Thread [Next in Thread]