#1833 How to localize AbstractMain help?

Xan Mon 12 Mar 2012

Hi,

I use AbstractMain . I use this example

I want to know how to localize the helping text, in my case:

g$ fan xtz.fan 

Usage:
   xtz [options] <action>
 Arguments:
   action    add|list
 Options:
   -help, -?    Print usage help

 [19:54:30 12-Mar-12] [err] [xtz] Missing arguments

And how to change the error message for only "Error: Missing args"?

Thanks in advance, Xan

brian Mon 12 Mar 2012

AbstractMain doesn't have any localization support today. As a general principle, nothing designed for "programmers" like APIs, docs, or command line tools are designed for localization in Fantom. Although everything designed for end-users like fwt::Command, etc are designed for localization.

Xan Tue 13 Mar 2012

A very very pain for me!. AbstractMain usage message is for users, at least in my case, because I will have users in catalan language with no knowledge of english.

1) Can I modify fantom internal code for achieve that?

2) Can you include it for next releases?

Thanks a lot,

KevinKelley Tue 13 Mar 2012

That should be a pretty easy one to fix. Grab the source of AbstractMain, change the uses of strings, to use a localized version:

msg := "$<missingArguments=Missing arguments>"

and define the value for your keys ( missingArguments=donde esta wtf ) in a locale/xx-XX.props file.

The Localization covers... it's about as simple as it could be, I guess.

brian Tue 13 Mar 2012

Can I modify fantom internal code for achieve that?

I think the simplest thing is to just copy the code for AbstractMain or subclass and make your changes.

Xan Tue 13 Mar 2012

How can I make these changes in subclass of AbstractMain? Can you say the steps I have to follow?

Thanks,

brian Wed 14 Mar 2012

Depending on how much you want to customize things you might just subclass AbstractMain and override usage to print usage using localized strings. If you really want to localize all the errors and whatnot, then I'd suggest just copying the entire source file and changing it to suite your purposes.

Xan Wed 14 Mar 2012

Mmm.. okay. I think override usage is my solution.

Thanks,

Login or Signup to reply.