Hacker News new | past | comments | ask | show | jobs | submit login

There's always an exception. You have two choices.

First: you might split it into three strings and trust the translator to handle it.

For example, you might pick:

  "Your query matched %(filecount)s in %(directorycount)s"?
  "%g files"
  "%g directories"
with appropriate plurals for the %g ones.

Another translator might pick:

  "Your query %(filecount)s %(directorycount)s"?
  "matched %g files"
  "in %g directories"
to get the flexibility they need.

You only hit a problem there when you get one word that is requires declination dependent on both numbers in a way that you can't fit to be contiguous with the numbers. It's not foolproof, but it's certainly enough flexibility if you're willing to re-word things slightly.

Alternatively, and this is my favoured way, you can have the result of a plural lookup be a second msgid, for example:

  msgid "files_found_by_n_directories"
  msgstr[0] "files_found_directory_0"
  msgstr[1] "files_found_directory_1"
  msgstr[2] "files_found_directory_2"
  
  msgid "files_found_directory_0"
  msgstr[0] "Your query didn't match any files"
  msgstr[1] "Your query matched a file in no directories"
  msgstr[2] "Your query matched %(file)g files in no directories"
  
  msgid "files_found_directory_1"
  msgstr[0] "Your query didn't match any files in a directory"
  msgstr[1] "Your query matched %(file)g file in a directory"
  msgstr[2] "Your query matched %(file)g files in a directory"
  
  msgid "files_found_directory_2"
  msgstr[0] "Your query didn't match any files in %(directories)g directories"
  msgstr[1] "Your query matched %(file)g file in %(directories)g directories"
  msgstr[2] "Your query matched %(file)g files in %(directories)g directories"



Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: