X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



4183 Rate this article:
No rating

Example of a multi-language widget application with IDL


This Article shows an example of a widget application in IDL that will support different languages depending on the OS language

1. Identify the OS language programmatically: default language will be English in the example below

    Result = LOCALE_GET( )
  if STREGEX(result,'(.*)_.*\..*',/BOOLEAN) then $
     language=(STREGEX(result,'(.*)_.*\..*',/EXTRACT,/SUBEXPR))[1] $
  else $
     language='English'

 

2. Create the language library: all language files described below should be saved in the same directory

    A. Save the text below in a file called langcat.dtd

****************************************
<!ELEMENT IDLffLangCat (LANGUAGE*)>
  <!ATTLIST IDLffLangCat
    APPLICATION CDATA #IMPLIED
    VERSION CDATA #IMPLIED
    AUTHOR CDATA #IMPLIED
    DATE CDATA #IMPLIED
  >
<!ELEMENT LANGUAGE (KEY*)>
  <!ATTLIST LANGUAGE
    NAME CDATA #REQUIRED
  >
<!ELEMENT KEY (#PCDATA)>
  <!ATTLIST KEY
    NAME CDATA #REQUIRED
    TYPE CDATA #IMPLIED
  >

****************************************

 

    B. Create an English language catalog : save the text below in the file called english.cat . All language catalogs should have the .cat extension

 ****************************************
< ?xml version='1.0' encoding='ISO8859-1'?>
< !DOCTYPE IDLffLangCat SYSTEM 'langcat.dtd'>
< IDLffLangCat APPLICATION="Widget Lang" VERSION="1.0" AUTHOR="Exelis VIS- Support">
< LANGUAGE NAME='English'>

< KEY NAME='MENU_FILE'>File</KEY>
< KEY NAME='MENU_IMPORT'>Import ASCII</KEY>
< KEY NAME='MENU_SAVE'>Save sondes</KEY>
< KEY NAME='MENU_OPTIONS'>Options</KEY>

< /LANGUAGE>
< /IDLffLangCat>

 
 ****************************************

    

     C. Create a second language catalog - French for example-: save the text below in the file called francais.cat. All language catalogs should have the .cat extension


****************************************
<?xml version='1.0' encoding='ISO8859-1'?>
<!DOCTYPE IDLffLangCat SYSTEM 'langcat.dtd'>
<IDLffLangCat APPLICATION="Widget Lang" VERSION="1.0" AUTHOR="Exelis VIS- Support">
<LANGUAGE NAME='French'>

<KEY NAME='MENU_FILE'>Fichier</KEY>
<KEY NAME='MENU_IMPORT'>Fichier de sondes ASCII</KEY>
<KEY NAME='MENU_SAVE'>Sauvegarder les sondes</KEY>
<KEY NAME='MENU_OPTIONS'>Les Options</KEY>

</LANGUAGE>
</IDLffLangCat>

****************************************

 

   D. Create a third language catalog - Russian for example-: save the text below in the file called russian.cat. Make sure that this file is saved with UTF-8 encoding. It is an option when you save a file using most text editors. All language catalogs should have the .cat extension. NOTE: In order for this to work properly, several settings must be changed in the Region and Language portion of the Control Panel. See the following help article for instructions on how to get Russian characters to work: http://www.exelisvis.com/Support/HelpArticlesDetail/TabId/219/ArtMID/900/ArticleID/4683/4683.aspx     

It should also be noted that the encoding for the language catalog has to be altered for Russian characters to be read from the language catalog, This is set on the first line of each language catalog.   


****************************************
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE IDLffLangCat SYSTEM 'langcat.dtd'>
<IDLffLangCat APPLICATION="Widget Lang" VERSION="1.0" AUTHOR="Exelis VIS- Support">
<LANGUAGE NAME='Russian'>

<KEY NAME='MENU_FILE'>привет </KEY>
<KEY NAME='MENU_IMPORT'>э оборотное</KEY>
<KEY NAME='MENU_SAVE'>і десятеричное</KEY>
<KEY NAME='MENU_OPTIONS'>привет </KEY>

</LANGUAGE>
</IDLffLangCat>

****************************************


3. Create the code to build the widget application: the example is composed of a base widget including a menu and a button

As a test you can comment-uncomment line 4 or 5 of the code to test the English or French library. When it works you can replace these lines by the command line described at step 1 of this document.

This codeonly displays the widget : it does not include an event handler

This code example should be saved in the same directory as the language catalogs.


*******************************************
PRO test_widget_lang
       
    path=FILE_DIRNAME((ROUTINE_INFO('test_widget_lang',/SOURCE)).path)
    language='English'
    ;language='french'
    ;language = 'russian'


    oCatalog=OBJ_NEW('IDLffLangCat',language,APP_NAME='Widget Lang',APP_PATH=path)
 
    wBase=WIDGET_BASE(TITLE='Widget_test' $
       ,MBAR=wMenuBar,COLUMN=1,/BASE_ALIGN_CENTER $
       ,xsize=300,ysize=100)

   wFileButton=WIDGET_BUTTON(wMenuBar,VALUE=oCatalog->Query('MENU_FILE'),/MENU)
   wImportButton=WIDGET_BUTTON(wFileButton,VALUE=oCatalog->Query('MENU_IMPORT'))
   wSaveButton=WIDGET_BUTTON(wFileButton,VALUE=oCatalog->Query('MENU_SAVE'))
   wOptionsButton=WIDGET_BUTTON(wbase,VALUE=oCatalog->Query('MENU_OPTIONS'))

   WIDGET_CONTROL,wBase,/REALIZE

END

*******************************************

 

 

____________________________________________________

Reviewed by DS on 7/23/2014

 

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »