Boost logo

Boost Users :

From: Pavel Syomin (syomin_at_[hidden])
Date: 2007-10-24 02:20:27


Hi to all!

I am writing some application that uses program_options. This
application interacts with user using non-english language. Is there any
way to translate "what" messages from exceptions to another language? At
now I found only one way (rather hack :) ):

static void store(const basic_parsed_options<char> &options,
          variables_map &variables)
{
    try {
        program_options::store(options, variables);
    }

    catch(unknown_option &error) {
        const char *what = error.what();
        static const char prefix[] = "unknown option ";

        if(!strncmp(what, prefix, sizeof(prefix) - 1))
            throw logic_error("îÅÉÚ×ÅÓÔÎÁÑ ÏÐÃÉÑ: " +
                        string(what + sizeof(prefix) - 1));
        throw logic_error("îÅ×ÅÒÎÙÊ ÆÏÒÍÁÔ ËÏÍÁÎÄÎÏÊ ÓÔÒÏËÉ");
    }
}

Another way is to redefine function
invalid_command_line_syntax::error_message(), but in such case we can
translate only some messages.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net