i18n (and program_options)
Hi, I am using spirit and program_options so far. When Boost.Program_options fails to parse some command line options it throws an exception (which is fine). So far, I write (if e is such an exception) e.what() to stderr. An obvious example of the the output I get is 'unknown option ...' I would like to present my users a text in their own language (i.e. german). Does Boost or Boost.Program_options support i18n? If yes, how can I set the language to use? (Or is the intended use to catch the exception, analyze it and produce my own translation?) Best regards, Christoph
Christoph Duelli wrote:
Hi,
I am using spirit and program_options so far. When Boost.Program_options fails to parse some command line options it throws an exception (which is fine). So far, I write (if e is such an exception) e.what() to stderr. An obvious example of the the output I get is 'unknown option ...'
I would like to present my users a text in their own language (i.e. german). Does Boost or Boost.Program_options support i18n? If yes, how can I set the language to use? (Or is the intended use to catch the exception, analyze it and produce my own translation?)
Hi Christoph, unfortunately, there's no standard solution in Boost for that. IMO, the right solution would be for all libraries to throw exceptions like this: throw ........ boost::format(boost::i18n("error %1") % error_code)); and boost::i18n to be no-op, but allow the user to provide its own hook: boost::set_i18n_hook(&gettext_i18n); Unfortunately, it might require a lot of discussion to settle on *any* boost-wide solution. If you're interested to start such discussion, try posting to developer's list. - Volodya
participants (2)
-
Christoph Duelli
-
Vladimir Prus