Getting a Nearest Equivalent Language

In this example, the system language is ELangCanadianEnglish and there is no exact match of the resource file on the system. The application calls BaflUtils::NearestLanguageFileV2() to get the closest match. There are three available resource files:

  • c:\FileMenu.rsc is the language-neutral resource file.

  • c:\FileMenu.r01 is for ELangEnglish.

  • c:\FileMenu.r10 is for ELangAmerican.


  1. In the application, define a string with the neutral-language resource file name.

    _LIT(KRscFilename, "C:\\FileMenu.rsc"); 
  2. Create a session with the File Server to search the file system for available resource files.
    RFs fileServerSession;
  3. Construct a buffer to save a resource file name. The buffer takes the neutral-language resource file name as a input parameter to BaflUtils::NearestLanguageFileV2(). It will be updated with a new value after the call.
    TBuf<256> filename;
  4. Define a TLanguage as a return parameter for the nearest equivalent language.
    TLanguage lang=ELangNone;
  5. Get the nearest language.
    BaflUtils::NearestLanguageFileV2(fileServerSession, filename, lang);
  6. Close the session with the File Server.
    CleanupStack::PopAndDestroy (&fileServerSession);


The filename parameter is updated as "c:\\FileMenu.r10" which is the closest resource file for ELangCanadianEnglish. The lang parameter is returned as ELangAmerican (value 10) which is the nearest equivalent language.