[Toybox] Error messages and internationalization.

Rob Landley rob at landley.net
Thu Apr 4 17:15:55 PDT 2013

Ok, I need to ask an opinion here. The authors of the recent ifconfig  
submission are from Japan (I think) but they're using longish english  
error messages.

I've been trying to keep my error strings as concise as possible. A  
chunk of examples from the current code turned up by a quick grep:

./lib/args.c:    error_exit("Unknown option %s", gof->arg);
./lib/args.c:    error_exit("No '%c' with '%c'", opt->c, bad->c);
./lib/lib.c:  if (close(fd)) perror_exit("xclose");
./lib/lib.c:    if (fd == -1) perror_exit("xdup");
./lib/lib.c:  if (!f) perror_exit("No file %s", path);
./lib/lib.c:  if (ret < 0) perror_exit("xread");
./lib/lib.c:  if (len != readall(fd, buf, len)) perror_exit("xreadall");
./lib/lib.c:  if (len != writeall(fd, buf, len)) perror_exit("xwrite");
./lib/lib.c:  if (offset<0) perror_exit("lseek");
./lib/lib.c:  if (!buf) perror_exit("xgetcwd");
./lib/lib.c:  if(stat(path, st)) perror_exit("Can't stat %s", path);
./lib/lib.c:  if (!new) perror_exit("realpath '%s'", path);
./lib/lib.c:  if (chdir(path)) error_exit("chdir '%s'", path);
./lib/lib.c:      if(rc) perror_exit("mkpath '%s'", path);
./lib/lib.c:  if (setuid(uid)) perror_exit("xsetuid");
./lib/lib.c:      if (*c) error_exit("not integer: %s", numstr);

The vast majority of those are the name of the function that failed (in  
a perror_exit, followed by a presumably translated error string from  

The reason I'm doing this is to be easier on non-english speakers.  
Since I'm not translating toybox's messages, it doesn't seem reasonable  
to expect non-english speakers to learn more than a few words to  
understand toybox's various error messages.

But I don't know how helpful this actually is. I notice ifconfig using  
descriptive error strings like:

  Invalid Port Number '%s' Port Number should be in [1-65535] range

I'd have phrased that as "bad port %s (need 1-65535)" or something like  
that. On the theory that people might be able to learn "bad" and  
"need", especially if they're repeated often enough in the other error  
messages. But "Invalid" is asking a lot more of a reader who may not  
even be comfortable with the latin alphabet.

More or less I'm asking them to learn "bad", "need", "not", "unknown",  
"no", and "can't". Then guess the rest from context. I can be a little  
more lenient when it's perror_exit() instead of error_exit(), because  
then a libc translated error message gets appended so 'nonsense  
nonsense nonsense: "yourfilename": permission denied' is understandable  
whatever the nonsense is, and if that's true I can skip the nonsense  
entirely or just put "bad".

But I'm a native english speaker. I don't know if this is an effective  
approach. Does anybody who ISN'T a native english speaker have an  


P.S. I'm not doing the gnu/dammit _("string") thing. This is a  
self-contained multicall binary with no external dependencies, message  
databases are an external dependency.)

P.P.S. I know I have to cleanup a lot of the external submissions. I'm  
putting stuff in the "pending" directory these days to remind myself to  
do this sort of thing. I need to do error message cleanup on  
toys/posix/cut.c and toys/other/vmstat.c and toys/other/login.c. And  
yes, this makes the english worse and the error messages less  
expressive, but I have a _reason_. What I'm asking right now is whether  
it's a good reason.  (Sigh. Waaaay too much of what I'm doing here is  
too darn subtle. I write giant web pages trying to explain stuff and  
still don't cover topics like this...)

P.P.P.S. I'm aware that the help text doesn't get translated either.  
But they already have localized versions of posix and such, there's  
existing docs they can look at there and then see we support "-l",  
"-p", and "-q"...

More information about the Toybox mailing list