Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
a while back, i put together a little script with some serious help from some people i know. its gone through a lot of maturing since i posted it to the monastery. i think it still has a ways to go, however a good deal of people out there have written in appreciation of its existance. the funny thing is, most of them are outside of the english-speaking world.
i'm working at putting in some basic multi-language support. its not much verbage, and i was hoping that some of the community of monks could lend a hand.
my spanish is so/so and my french is mediocre. i'm trying for english/french/german/portuguese/spanish support. there is really no more than 70 words translation, so if you could take a minute to look at what i have below, i'd appreciate it.

oh, there's some perl in there as well, which i dont think i'd mind hearing some comments on as well :-)

The code below is how i am allowing users to select a language. i'm not sure if its the best manner, but i figured creating only one instance of a language hash is better than creating one for each language.

For translation, I know some of the single word translations would be difficult without seeing how they are used in context. after the code, i'm including a full list of in context sentences...

my $language = ""; # your native language # "de" "es" "fr" "pt" "uk" ## create hash of various language specific output my %lang = (); ## set the elected language to lowercase $language = lc($language); ## deutsch if ($language eq "de") { ## español } elsif ($language eq "es") { $lang{flag_req} = "Se requiere al menos una opción."; $lang{run_help} = "Si se necesita ayuda, corre $0 --help"; $lang{no_open} = "No se puede abrir el archivo especificado c +on --list"; $lang{chk_path} = ""; $lang{no_nodes} = ""; $lang{no_snmp} = ""; $lang{no_tftp} = ""; $lang{exp_tftp} = ""; $lang{no_file} = ""; $lang{no_updown} = ""; $lang{version} = ""; $lang{no_log} = ""; $lang{exp_path} = ""; $lang{copy_start} = ""; $lang{no_catos} = ""; $lang{no_depmib} = ""; $lang{cp_success} = ""; $lang{on} = ""; $lang{from} = ""; $lang{to} = ""; $lang{by} = ""; $lang{cp_from} = ""; $lang{cp_to} = ""; $lang{to_nvram} = ""; $lang{cp_nvram} = ""; $lang{from_nvram} = ""; $lang{wr_success} = ""; $lang{rel_success} = ""; $lang{init} = ""; ## français } elsif ($language eq "fr") { ## portugues } elsif ($language eq "pt") { ## english } else { $lang{flag_req} = "Pancho requires some flags to be specified. +"; $lang{run_help} = "Please try running $0 --help"; $lang{no_open} = "Can't open external file specified with --l +ist."; $lang{chk_path} = "Please check the path and ensure file exist +s."; $lang{no_nodes} = "You have not specified a node or a list of +nodes to act upon!"; $lang{no_snmp} = "You have not specified an SNMP community."; $lang{no_tftp} = "You have not specified a tftp server."; $lang{exp_tftp} = "In order to tftp a configuration to a remot +e device"; $lang{no_file} = "you must indicate a specific filename using + -f."; $lang{no_updown} = "You cannot upload and download at the same +time."; $lang{version} = "This is Pancho version"; $lang{no_log} = "Can't open file specified for logging."; $lang{exp_path} = "Please check the path specified."; $lang{copy_start} = "Copying configurations to and from startup- +config"; $lang{no_catos} = "is not possible using the CatOS."; $lang{no_depmib} = "is not possible using deprecated mibs."; $lang{cp_success} = "Successfully copied config to"; $lang{on} = "on"; $lang{from} = "from"; $lang{to} = "to"; $lang{by} = "by"; $lang{cp_from} = "copied from"; $lang{cp_to} = "copied to"; $lang{to_nvram} = "to nvram on"; $lang{cp_nvram} = "copied to nvram on"; $lang{from_nvram} = "from nvram on"; $lang{wr_success} = "Successfully wrote config to memory on"; $lang{rel_success} = "Successfully initialized a reload of"; $lang{init} = "initialization of reload on"; }

Context

"\nPancho requires some flags to be specified.\nPlease try running $0 --help\n\n"

"\nCant open external file specified with --list.\nPlease check the path and ensure file exists.\n\n"

"\nYou have not specified a node or list of nodes to act upon!\n\n"

"\nYou have not specified an SNMP community.\n\n"

"\nYou have not specified a tftp server.\n\n"

"\nIn order to tftp a configuration to a remote device\nyou must indicate a specific filename using -f.\n\n"

"\nYou cannot upload and download at the same time.\n\n"

"\n This is Pancho version $rcs\n\n"

"\nCant open file specified for logging.\nPlease check the path specified.\n\n"

"\nThe following hosts could not be resolved: @failed\n\n"

"\nCopying configurations to and from startup-config\nis not possible using the CatOS.\n\n"

"\nCopying configurations to and from startup-config\nis not possible using deprecated mibs.\n\n"

"\nSuccessfully copied config to $args->{h} from $tftpserver\n\n"

"$format config <$filename> copied from $tftpserver to $args->{h} by $user\n"

"\nSuccessfully copied config to nvram on $args->{h} from $tftpserver\n\n"

"$format config <$filename> copied from $tftpserver to nvram on $args->{h} by $user\n"

"\nSuccessfully copied config to $tftpserver from $args->{h}.\n\n"

"$format config copied to $tftpserver from $args->{h} by $user\n"

"\nSuccessfully copied config to $tftpserver from nvram on $args->{h}.\n\n"

"$format config copied to $tftpserver from nvram on $args->{h} by $user\n"

"\nSuccessfully wrote config to memory on $args->{h}.\n\n"

"$format config copied to nvram on $args->{h} by $user\n"

"\nSuccessfully initialized a reload of $args->{h}.\n\n"

"$format initialization of reload on $args->{h} by $user\n"

humbly -c


In reply to multi-lingual support... by c

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-19 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found