| Re: Internationalization [message #35050 is a reply to message #34969] |
Thu, 08 May 2003 13:16  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Miguel Angel Cordoba wrote:
> Hi,
> I want to internationalize my aplications but I don't know how
> to do it. I have the translated files of the messages of the application
> but I don't know if IDL can do a precompiled option that change
> the messages in the code in the selected language. Another solution
> is to read the file of messages and store it in and string array, but I
> think
> this solution is not a good idea.
>
>
> Thanx
>
I believe the internationalition isn't yet supported.
I would suggest to do something like this.
you need always txt files named to the belonging routine
e.g. my_prog_lang_en.txt my_prog_lang_de.txt
----routine name lang_message.pro -------
FUNCTION lang_message_fetch_file,file
txt=MAKE_ARRAY(/STRING,fileline(file))
OPENR,lun,/GET_LUN,file
READF,lun,txt
FREE_LUN,lun
RETURN,txt
END
FUNCTION lang_message,_extra=e
IF is_structure(e) THEN BEGIN
l_tags=get_tagname(e,'lang*')
IF is_structure(l_tags) EQ 1 THEN BEGIN
language=(TAG_NAMES(l_tags))[0]
HELP,call=call
routine=(strsplit(call[1],' ',/extract))[0]
msg_file=STRLOWCASE(routine+'_'+language+'.txt')
comments=lang_message_fetch_file(msg_file)
ENDIF ELSE BEGIN
HELP,call=call
routine=(strsplit(call[1],' ',/extract))[0]
msg_file=STRLOWCASE(routine+'_lang_de.txt')
comments=lang_message_fetch_file(msg_file)
ENDELSE
ENDIF ELSE BEGIN
HELP,call=call
routine=(strsplit(call[1],' ',/extract))[0]
msg_file=STRLOWCASE(routine+'_lang_de.txt')
comments=lang_message_fetch_file(msg_file)
ENDELSE
RETURN,comments
END
------
Example script:
pro my_prog,_extra=e
message,lang_message(_extra=e),/info
end
------------
called:
my_prog,/lang_de>
IDL> my_prog,/lang_de
% MY_PROG: Beispiel fᅵr einen Test.
or
my_prog,/lang_en
IDL> my_prog,/lang_en
% MY_PROG: Example
the routine get_tagname you can get from our library:
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/get_tagname.tar.gz
or as idl 5.x bninary
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/get_tagname.sav
For further routines and licensing please have a look at
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
best regards
Reimar
--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
|
|
|
|