[Xfce-i18n] Generating unique duplicate names

Benedikt Meurer benedikt.meurer at unix-ag.uni-siegen.de
Tue Nov 8 17:56:46 CET 2005

Hey Daichi and translators,

The following piece of code is used to generate unique names for
duplicated/linked files:

static const gchar * const THUNAR_NAMING[3][2] =
    N_ ("copy of %s"),
    N_ ("link to %s"),
    N_ ("another copy of %s"),
    N_ ("another link to %s"),
    N_ ("third copy of %s"),
    N_ ("third link to %s"),

static inline gchar*
thunar_naming_make_next (const gchar     *source_name,
                         guint            n,
                         ThunarNamingMode mode)
  /* handle the easy cases */
  if (G_LIKELY (n == 0))
    return g_strdup (source_name);
  else if (n <= 3)
    return g_strdup_printf (gettext (THUNAR_NAMING[n - 1][mode]),

  /* we need to use ngettext here */
    return g_strdup_printf (ngettext ("%uth copy of %s",
                                      "%uth copy of %s", n),
                            n, source_name);
    return g_strdup_printf (ngettext ("%uth link to %s",
                                      "%uth link to %s", n),
                            n, source_name);

For example, when you duplicate a file, it will call
thunar_naming_make_next() until a filename is found, for which no file
exists. Let's say, you duplicate "test.txt", then you'll get "copy of
test.txt". When you duplicate again, you'll get "another copy of
test.txt", then "third copy of test.txt", "4th copy of test.txt", and so on.

As you can see the first 3 possibilities ("copy of", "another copy" and
"third copy of") are special cases, and the remaining are just the
number with an appended "th". This is required for english (because
there's "st", "nd" and "rd" for 1 to 3, but "th" for (most of) the

Now my question is: Is the above easily translatable to other languages
(I know that it'll work for german and a bunch of other languages, but
whatever e.g. non-european languages)? I don't care if the 20th
duplicate's name doen't look right, but the first 1-5 duplicate names
should be properly translatable.


More information about the Xfce-i18n mailing list