Translation results in ?????
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: Translation results in ?????

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    Germany
    Posts
    16

    Translation results in ?????

    Hy all,

    i have an not Unicode MFC Application, programmed in Visual Studio 2010 with C++. For translating my software, i have extraced all the resources into a resource -dll. This dll is translated with a tool, visual localize, to russian language i.e.. .

    I load the dll with
    this->m_hLanguageDLL=LoadLibrary(csFullDllName);
    ...
    AfxSetResourceHandle(m_hLanguageDLL);
    ..

    Most parts work well, but some text is displayes as ???? only. I reduced the problem to text, that is loaded from the resource with

    CString csTmp;
    ...
    csTmp.Format( IDS_STRING246 );

    this results in the wrong text.

    Can anybody give me a clou, what is wrong with this concept or how to get the correct behavior. Opening the dll in Visual Studio, the text entries are translated correctly.

    english with the same mechanism works fine.

    Thanks for any kind of help.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,421

    Re: Translation results in ?????

    What language is used "ta match the language version of the non-Unicode programs..."? (Control Panel -> Regional and Language Options ->Advanced)
    Victor Nijegorodov

  3. #3
    Join Date
    May 2004
    Location
    Germany
    Posts
    16

    Re: Translation results in ?????

    Quote Originally Posted by VictorN View Post
    What language is used "ta match the language version of the non-Unicode programs..."? (Control Panel -> Regional and Language Options ->Advanced)
    After switching this to russian, the "????" in the dialogs are gone, but those in the text, with csTmp.Format(IDS_STRING246) still are there.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,421

    Re: Translation results in ?????

    Quote Originally Posted by gintonic42 View Post
    After switching this to russian, the "????" in the dialogs are gone, but those in the text, with csTmp.Format(IDS_STRING246) still are there.
    What exactly are you trying to achieve with this Format? How does the IDS_STRING246 string look like?
    Victor Nijegorodov

  5. #5
    Join Date
    May 2004
    Location
    Germany
    Posts
    16

    Re: Translation results in ?????

    I try to put all strings in my app into the resources, so i can translate the resource-dll. If i use

    csTmp.Format(_T("Hello World!"))

    it works fine, but the "Hello World!" does not appear in the dll so my client cannot translate it.

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,421

    Re: Translation results in ?????

    Quote Originally Posted by gintonic42 View Post
    ... the "Hello World!" does not appear in the dll so my client cannot translate it.
    What do you mean by "does not appear in the dll"?
    It cannot appear there automatically, it is you who has to put this text in the dll string table!
    After you put ii in the string table you should use CString::LoadString to load it in the CString object.
    Victor Nijegorodov

  7. #7
    Join Date
    May 2004
    Location
    Germany
    Posts
    16

    Re: Translation results in ?????

    Same result. Of course the string is in the resource file. It is found in the english, german, ... version. The russian recource-dll also contains the string.

    ...
    IDS_STRING246 "Programmbeschreibung"
    ...

    But if i load it

    + csTmp "???????? ?????????" ATL::CStringT<char,StrTraitMFC_DLL<char,ATL::ChTraitsCRT<char> > >

    appears in the debugger and also in the application

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,421

    Re: Translation results in ?????

    Please, show your actual code that icludes loading the string and using it to be shown in UI!
    And please, stop posting some pseudo code patterns, especially because they are different in your every new post.
    Victor Nijegorodov

  9. #9
    Join Date
    May 2004
    Location
    Germany
    Posts
    16

    Re: Translation results in ?????

    Ok, very easy


    HMODULE m_hLanguageDLL=LoadLibrary(csFullDllName);
    AfxSetResourceHandle(m_hLanguageDLL);

    CString csTmp;
    csTmp.Format( IDS_STRING246 );
    AfxMessageBox(csTmp);


    and the result is a message box with only ???????????
    If i use LoadString instead of Format the same result. The number of ? is the same as the letters in the text.

    Name:  Fragez.jpg
Views: 58
Size:  5.2 KB

    Sorry for my mixing up.

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,421

    Re: Translation results in ?????

    And your IDS_STRING246 string is "Programmbeschreibung"?
    But it does not use any cyrillic characters!
    Victor Nijegorodov

  11. #11
    Join Date
    May 2004
    Location
    Germany
    Posts
    16

    Re: Translation results in ?????

    No, in the dll loaded, the IDS_STRING is allready translated to russian. I found out something new. If i use this code:

    wchar_t buf[256];
    AfxLoadString(IDS_STRING663,buf,256);
    csTmp=buf;

    in buf the text is correct. Then converted to CString csTmp it results in the ????????

  12. #12
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,421

    Re: Translation results in ?????

    The default conversion from wide char to MBCS is done using WideCharToMultiByte API which first paramaeter (CodePage ) defines how to convert.
    ATL CString uses _AtlGetConversionACP() function to obtain the CodePage and the return value seems to not correspond the page you need to the proper conversion. See details here
    Victor Nijegorodov

  13. #13
    Join Date
    May 2004
    Location
    Germany
    Posts
    16

    Re: Translation results in ?????

    Thanks Victor,

    i finally found out, it was not a coding problem, but a problem in the settings of Windows. With the correct settings and the russian language installed correctly, the dialogs are displayed correct and also the messages load correct. Either with Format or LoadString.

    Thanks for your help.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center