Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Loading resources from resource files

Using the AEE_RES_LANGDIR and AEE_RES_LANGSUF macros with ISHELL_LoadResXX() simplifies language determination for resource files. These macros are defined in AEEShell.h, as follows:

  • AEE_RES_LANGSUF is defined as {langsuf}
  • AEE_RES_LANGDIR is defined as {langdir}

The Shell determines the language and replaces the macro string with the language code for the current language. For example, “{langdir}sample.bar” becomes “en/sample.bar” when English is the current language.

Loading resources from language subdirectories

When resource files are stored in separate language subdirectories, the application can use the AEE_RES_LANGDIR macro to locate the appropriate resource file.

In this example, APP_SAMPLE_FILE_SUB is defined using AEE_RES_LANGDIR. APP_SAMPLE_FILE_SUB is then used when calling ISHELL_LoadResString().

...
#define APP_SAMPLE_FILE_SUB   AEE_RES_LANGDIR "sample.bar"

ISHELL_LoadResString (pMe->a.m_pIShell, APP_SAMPLE_FILE_SUB,
                      IDS_STRING1, szBuf, sizeof (szBuf));
...

When the application calls ISHELL_LoadResString(), Brew MP replaces the AEE_RES_LANGDIR macro "lang/" for AEE_RES_LANGDIR, where lang is the current language, and attempts to open the file. If that does not succeed the macro is replaced with the empty string and Brew MP attempts to open the file again. If the file is opened successfully, Brew MP loads the requested resource from that file. If the resource does not exist in the opened file, an error is returned.

Loading resources from files with language suffixes

When resource files are all in one directory with file names contains the language code as a suffix, the application can use the AEE_RES_LANGSUF macro to locate the appropriate resource file.

In this example, APP_SAMPLE_FILE_SUFIIX is defined using AEE_RES_LANGSUF. APP_SAMPLE_FILE_SUFFIX is then used when calling ISHELL_LoadResString().

...
#define APP_SAMPLE_FILE_SUFFIX "sample" AEE_RES_LANGSUF ".bar"

ISHELL_LoadResString(pMe->a.m_pIShell, APP_SAMPLE_FILE_SUFFIX,
                     IDS_STRING1, szBuf, sizeof (szBuf));
...

When the application calls ISHELL_LoadResString(), Brew MP replaces the AEE_RES_LANGSUF macro with "_lang", where lang is the current language, and attempts to open the file. If that does not succeed the macro is replaced with the empty string and Brew MP attempts to open the file again. If the file is opened successfully, Brew MP loads the requested resource from that file. If the resource does not exist in the opened file, an error is returned.