CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 1999
    Location
    Sweden
    Posts
    38

    Multi-lingual support in DLLs

    WANTED!

    If any of you have any good ideas how to make an application support multiple languages, where e.g. all dialog text is stored in a DLL for each country, and just by switching DLL's, also switching language. We have tries different methods, one is to have different textfiles that you include in different rc-files, but this renders the resource editor unusable. We've also tried having the texts replaced at runtime, where we only insert a keyword in the resource editor. There must be a better way out there!(?) Please contact me a.s.a.p. if you know of a way.


  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Multi-lingual support in DLLs

    Did you try something like:

    LoadLibrary("English.dll");
    OR
    LoadLibrary("German.dll");
    OR
    LoadLibrary(whatever);

    where "whatever" is the name of the DLL with string resources? You could easily place the name of the current language in the registry or an INI file of the application. That way, you know which DLL to load at runtime in your application.

    Also, the ID's of all of the resource strings identifies your strings. When you call

    LoadString(hInstanceDLL, IDS_HELLO, szBuffer, 100);

    IDS_HELLO is defined in English.DLL as "HELLO", Spanish.DLL as "HOLA", etc.

    Regards,

    Paul McKenzie


  3. #3
    Join Date
    Jun 1999
    Location
    Sweden
    Posts
    38

    Re: Multi-lingual support in DLLs

    Hi and thanks for you quick answer.

    You are right, this is exactly what I need. Now to problem number two. Maby you have any suggestions on this matter as well.

    The text of the controls in e.g. dialogs has to be updated. And this is the problem.

    I figured on setting the text of e.g. a button to "//IDS_OK" and then read the buttons text, then strip the "//" is found and use the FindResource function to load the string from a string table in e.g. "ENGLISH.DLL". I've loaded the DLL ok, but I can't get the loading of the string to work.

    I would appreciate if you could tell me how to do it. A bit of code would be grand! :-)

    Thanks in advance.

    Best regards

    /Jonas

  4. #4
    Join Date
    May 1999
    Posts
    27

    Re: Multi-lingual support in DLLs

    Hi,

    You can find what your looking for in the CGTetris sample in codeguru. Look into the samples section and then "The Tetris clone CGTetris".
    In this sample they use DLLs which contain a the String resources for each language.
    I had the same problem as you, and this program answered all my questions !!

    Regards.

    Frédéric Naudeau.


  5. #5
    Join Date
    Jun 1999
    Location
    Sweden
    Posts
    38

    Re: Multi-lingual support in DLLs

    Hi Frédéric!

    Thank you so much for your help. I will look into that sample right away.

    Best regards

    Jonas Pettersson
    [email protected]

  6. #6
    Join Date
    Jun 1999
    Location
    Sweden
    Posts
    38

    Re: Multi-lingual support in DLLs

    Hi again.

    Unfortunatly I still can't make this work. In the example there wasn't any strings loaded from the resource, just some midi and wave resources. So I tried to make a string loader out of it, which might I add.. failed :-(

    here is the code that is supposed to load the string from the resource DLL (ENGLISH.DLL):

    //------------------------------------------
    CString LoadStr(CString sIDS)
    //
    // Loads a string from the current language support file.
    //
    {
    if (!s_hLangLib)
    s_hLangLib = LoadLibrary("ENGLISH.DLL");

    ASSERT(s_hLangLib);

    HRSRC hResInfo = ::FindResource(s_hLangLib, (LPCTSTR)sIDS, RT_STRING);

    // This is where this bugger fail. I get hResInfo == NULL no matter what I do, and
    // I've failed to find any sample code that actually loads a string. I've found several
    // that loads e.g. midi, avi, toolbars etc. But I can't seem to make it work when
    // I 'convert' it into a RT_STRING loader :-|

    if (hResInfo == 0)
    return "::1";

    HGLOBAL hRes = ::LoadResource(s_hLangLib, hResInfo);
    if (hRes == 0)
    return "::2";

    LPVOID pVoid = ::LockResource(hRes);

    if (pVoid == 0)
    return "::3";

    // This will later on return the actual string that
    // was loaded from the string table in ENGLISH.DLL
    return "OK";
    }



    Can you see what's wrong here?

    Best regards

    Jonas Pettersson
    [email protected]

  7. #7
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    8

    Re: Multi-lingual support in DLLs

    If you are using MS Visual C++ - MFC, C++ or C there is a new
    tool which may help you:

    The RapidTranslation System ! This is a collection of
    libraries an tools designed especially for the localization
    of Windows based applications.
    Version 2.5 supports the following features:

    - Switching of languages at application run-time. A comfortable
    dialog to do this is added to your application automatically.

    - The RapidTranslation Editor enables you (or translators,
    or even your customers) to create support for new languages
    in the easiest way: You just have to type the translation for
    your application's strings in an easy-to-use editor, say "save",
    and even without quiting your application you can switch it
    to the new language.

    - The ability of parsing c-format-strings makes it very easy for
    non-programmers to use the Editor: You can edit the text
    flowing around the placeholders, no knowledge about format
    strings is needed.

    - A special-character-dialogue enables the translator to select
    special characters by a mouseclick.

    - The version-update feature of RapidTranslation Editor assures
    you don't have to translate your application's texts a second
    time if you launch a new version, only the changed / added
    texts (this is determined automatically) have to be translated.

    - Adding RapidTranslation to new / existing applications
    is one of the easiest things:
    Just start the RapidTranslation Assistant. This tool analyses
    your project and helps you to do very little code changes.
    In most cases you have to add only 3 lines of code, and your
    application uses RapidTranslation.

    - A free edition of RapidTranslation is available now. It is only
    limited in the count of texts that can be translated, but for
    smaller projects it is sufficient. The testmode lets test you
    whether our program works correct. Every string of your application
    starts with a x and ends with a y.

    For further information about RapidTranslation, please look at
    http://www.rapidsolution.de/weben/down/down2.5.htm
    You can get the free edition there.

    I hope that solves your problem -

    Jan Horstmann

    ------------------------------------------------
    Jan Horstmann, Marketing
    RapidSolution Software GmbH, Technologiefabrik, Haid-und-Neu-Str.7, D-76131Karlsruhe
    Telefon +49-721-9658-601, Fax +49-721-9658-602
    [email protected], www.rapidsolution.de



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured