DTWAIN_LoadCustomStringResources

Top  Previous  Next

The DTWAIN_LoadCustomStringResources loads one of the DTWAIN text resource files for use by DTWAIN.

 

DTWAIN_BOOL DTWAIN_LoadCustomStringResources( LPCTSTR LanguageName );

 

Parameters 

LanguageName

Specifies the name of the language that contains the strings used by DTWAIN.  

 

Return Values

If the function succeeds, TRUE is returned.  If the function fails FALSE is returned.

 

Character specific version (the parameter LanguageName will either be an ANSI or a Unicode string)

ANSI version:

DTWAIN_LoadCustomStringResourcesA

Unicode version:

DTWAIN_LoadCustomStringResourcesW

 

Comments

The DTWAIN_LoadCustomStringResources function allows an application to load a file that contains the language strings used by DTWAIN for error messages (when DTWAIN_GetErrorString is called), when logging messages using DTWAIN_SetTwainLog, and for the custom strings used by the TWAIN Select Source dialog whenever DTWAIN_SelectSource2 is called.


Calling DTWAIN_LoadCustomStringResources will use the strings defined in a text file named "twainresourcestrings_<LanguageName>.txt" to override the equivalent strings used for DTWAIN messages.  For example, in C/C++:


DTWAIN_LoadCustomStringResources(_T("french"));


will load the resources found in file "twainresourcestrings_french.txt" (the _T() is a Windows API macro that converts the string-literal to the correct type, depending whether the application is ANSI or Unicode).

 


Creating your own custom language resources 


By default, DTWAIN has English, Portuguese (Brazilian), Spanish, Italian, German, French and Dutch resource files in the DTWAIN installation's text_resources directory (there may be additional files with each release of DTWAIN).  At runtime, these resource files should be located in the same directory where the DTWAIN DLL will reside.


The names of the files and the language they represent is as follows:


Resource file name

Language

 twainresourcestrings_english.txt

English

 twainresourcestrings_dutch.txt   

Dutch

 twainresourcestrings_french.txt

French

 twainresourcestrings_german.txt

German

 twainresourcestrings_italian

Italian

 twainresourcestrings_spanish

Spanish

 twainresourcestrings_portuguese_br

Portuguese (Brazilian)


If you want to create your own language resource, you can do this by utilizing these steps:


1) Use the file twainresourcestrings_english.txt as a baseline text file, and have the entire file translated to another language by using your favorite 

     translation program, translation service, or edit a new file manually if you are comfortable creating the entire translation yourself..


2) Name the translated file to twainresourcestrings_newlanguage.txt", where newlanguage is the language you translated the 

     English resources to.  For example, if the new language is Greek, the file would be named twainresourcestrings_greek.txt.   The part of 

     the file name that represents the language (in the above case, "greek"), will be used in the DTWAIN API call DTWAIN_LoadCustomStringResources


3) Make sure that the new resource file is located in the same directory as the other DTWAIN resources, i.e. where twainresourcestrings_english.txt is located 

     during the running of your DTWAIN application.


4) Change your DTWAIN application to add the following API call (after DTWAIN_SysInitialize is called) (C/C++ sample shown)


  DTWAIN_LoadCustomStringResources(_T("greek"));


Note that the name parameter used in DTWAIN_LoadCustomStringResources is the same name you gave the resource file (the part of the file name after the initial "_" 

character in the file name).


If everything goes well, you can test if the custom language resource has been loaded by calling DTWAIN_SetTwainLog and checking if the logging information shows up in the desired language.


Note that the resource text file can be encoded using UTF-8, and not just ASCII / ANSI.  Thus any language can be represented by using this method.



TWAIN State Transitions

None

 

Prerequisite Function Call(s)

DTWAIN_SysInitialize