Append external translation files to an application's translation list
#include <Ap.h> int ApAppendTranslation( char const *filename, char const *lang_extension );
This function is used to append external translation files to the application's translation list. It takes the translation file identified by filename, appends the lang_extension and looks for the translation file in the directory defined by the ABLPATH environment variable. If lang_extension is NULL, the current language extension is used.
This is useful when you want to share common text strings among many different applications. Essentially, you create a standalone application that contains a single picture module (widget database) of text strings. Then you use the PhAB Language Editor to translate the strings in this module. Once the database is created and translated, you can access it from another application.
Keep in mind when calling this function from a DLL that this function performs the language extension search based on the location of the executable or DLL associated with the current context, and appends the language translation to the current context. You must make sure that there is a current context. You most likely want your DLL to append a language translation to its own context, rather than the main program's context:
ApContext_t *old = ApSetContext( & AbContext ); ApAppendTranslation( filename, NULL ); ApSetContext( old ); // Restore the program's context
For more information about creating DLLs from PhAB applications, see “Making a DLL out of a PhAB application” in the Generating, Compiling, and Running Code chapter of the Photon Programmer's Guide.
Assuming ABLPATH has been set to /usr/photon/translations:
ApDBase_t *mytext_db; /* Open the text database. */ mytext_db = ApOpenDBaseFile( "/fullpath/mytext_db.wgtp" ); /* Set the translation to German. */ ApSetTranslation( "de_DE" ); /* Append the external German translation file to the current list. This will read the translation file "/usr/photon/translations/mystrings.de_DE" and append it to the application's current translation list. */ ApAppendTranslation( "mystrings", "de_DE" ); /* Get a translated text string. */ text = ApGetTextRes( mytext_db, "msg001" );
ApOpenDBase(), ApOpenDBaseFile(), ApSetTranslation(), ApGetTextRes()
International Language Support chapter of the Photon Programmer's Guide