Translate Program

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
El_isra
Experienced Solver
Experienced Solver
Posts: 50
Joined: Tue Apr 13, 2021 1:10 am
Location: Buenos Aires, Argentina
Contact:

Re: Translate Program

Post by El_isra »

doublemax wrote: Wed May 26, 2021 9:35 pm
El_isra wrote: Wed May 26, 2021 8:00 pm someone else tested the program and it isn't showing the Translated strings....
maybe I should try with wxWidgets 3.1.5??
Might be worth a try.

Here's the binary i created: If you dare to run exes from strangers, please try it out:
https://easyupload.io/ya2yg7
I created another code::blocks project, then i transfered the sources from the original project.
after building i got the same result...
El_isra
Experienced Solver
Experienced Solver
Posts: 50
Joined: Tue Apr 13, 2021 1:10 am
Location: Buenos Aires, Argentina
Contact:

Re: Translate Program

Post by El_isra »

doublemax wrote: Wed May 26, 2021 9:35 pm
El_isra wrote: Wed May 26, 2021 8:00 pm someone else tested the program and it isn't showing the Translated strings....
maybe I should try with wxWidgets 3.1.5??
Might be worth a try.

Here's the binary i created: If you dare to run exes from strangers, please try it out:
https://easyupload.io/ya2yg7
maybe you have linked a library or declared a macro that fixed the issue
El_isra
Experienced Solver
Experienced Solver
Posts: 50
Joined: Tue Apr 13, 2021 1:10 am
Location: Buenos Aires, Argentina
Contact:

Re: Translate Program

Post by El_isra »

doublemax wrote: Wed May 26, 2021 9:35 pm
El_isra wrote: Wed May 26, 2021 8:00 pm someone else tested the program and it isn't showing the Translated strings....
maybe I should try with wxWidgets 3.1.5??
Might be worth a try.

Here's the binary i created: If you dare to run exes from strangers, please try it out:
https://easyupload.io/ya2yg7
Could you send me a copy of your WxWidgets Build?

I've tried everything and nothing works.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Translate Program

Post by ONEEYEMAN »

Hi,
Did you try to build and run the sample?

Forget about C::B, its wizard and everything it does - it just an IDE.

Build the sample. Run the sample. See if it works.
Run the sample under debugger. Trace thru all its stuff.

THen see what you are doing in your own cpode differently.
Check where you placed the translation files.

Make it work based on the sample.

Thank you.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Translate Program

Post by PB »

As always, when troubleshooting wxTranslation issues, I recommend calling

Code: Select all

wxLog::AddTraceMask("i18n");
before initializing locale, obviously using debug build of wxWidgets. This will make wxWidgets output a lot of information about what is going on under the hood with translations and should make it possible to find out where it goes wrong. In particular, it shows what paths are searched for the message catalogs.

If you are using Code::Blocks, it unfortunately does not show output of wxLogDebug/Trace() calls and the program needs to be run under gdb directly.
For example, running this (where the message catalogs are not present)

Code: Select all

#include <wx/wx.h>
#include <wx/intl.h>

class MyApp : public wxApp
{
    wxLocale m_locale;
public:
    bool OnInit() override
    {
        wxLog::AddTraceMask("i18n");

        m_locale.Init();
        m_locale.AddCatalog("wxstd");
        m_locale.AddCatalog("test");

        wxLogMessage(_("Test"));
        return false;
    }
}; wxIMPLEMENT_APP(MyApp);
produces this

Code: Select all

warning: (i18n) adding 'en_US' translation for domain 'wxstd-3.1' (msgid language 'en_US')
warning: (i18n) looking for "wxstd-3.1.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US.WINDOWS-1252\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US.WINDOWS-1252
warning: (i18n)
warning: (i18n) looking for "wxstd-3.1.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US
warning: (i18n)
warning: (i18n) looking for "wxstd-3.1.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en
warning: (i18n)
warning: (i18n) adding 'en_US' translation for domain 'wxstd' (msgid language 'en_US')
warning: (i18n) looking for "wxstd.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US.WINDOWS-1252\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US.WINDOWS-1252
warning: (i18n)
warning: (i18n) looking for "wxstd.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US
warning: (i18n)
warning: (i18n) looking for "wxstd.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en
warning: (i18n)
warning: (i18n) adding 'en_US' translation for domain 'test' (msgid language 'en_US')
warning: (i18n) looking for "test.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US.WINDOWS-1252\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US.WINDOWS-1252
warning: (i18n)
warning: (i18n) looking for "test.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US
warning: (i18n)
warning: (i18n) looking for "test.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en
warning: (i18n)
warning: (i18n) string "Test" not found in locale 'en_US'.
warning: (i18n) string "%s Information" not found in locale 'en_US'.
warning: (i18n) string "Yes" not found in locale 'en_US'.
warning: (i18n) string "No" not found in locale 'en_US'.
warning: (i18n) string "OK" not found in locale 'en_US'.
warning: (i18n) string "Cancel" not found in locale 'en_US'.
warning: (i18n) string "Help" not found in locale 'en_US'.
warning: (i18n) string "OK" not found in locale 'en_US'.
El_isra
Experienced Solver
Experienced Solver
Posts: 50
Joined: Tue Apr 13, 2021 1:10 am
Location: Buenos Aires, Argentina
Contact:

Re: Translate Program

Post by El_isra »

ONEEYEMAN wrote: Sun Jun 13, 2021 5:01 am Hi,
Did you try to build and run the sample?

Forget about C::B, its wizard and everything it does - it just an IDE.

Build the sample. Run the sample. See if it works.
Run the sample under debugger. Trace thru all its stuff.

THen see what you are doing in your own cpode differently.
Check where you placed the translation files.

Make it work based on the sample.

Thank you.
both my code and the samples are working.
Doublemax compiled my program and it worked for him, while mine didn't work at all.
Probably wxWidgets build is causing the issue?
or perhaps mingw? I used Default MINGW For Code::Blocks to build wxWidgets, since any other toolchains stops without giving errors at Geometry.h line 620
El_isra
Experienced Solver
Experienced Solver
Posts: 50
Joined: Tue Apr 13, 2021 1:10 am
Location: Buenos Aires, Argentina
Contact:

Re: Translate Program

Post by El_isra »

PB wrote: Sun Jun 13, 2021 9:08 am As always, when troubleshooting wxTranslation issues, I recommend calling

Code: Select all

wxLog::AddTraceMask("i18n");
before initializing locale, obviously using debug build of wxWidgets. This will make wxWidgets output a lot of information about what is going on under the hood with translations and should make it possible to find out where it goes wrong. In particular, it shows what paths are searched for the message catalogs.

If you are using Code::Blocks, it unfortunately does not show output of wxLogDebug/Trace() calls and the program needs to be run under gdb directly.
For example, running this (where the message catalogs are not present)

Code: Select all

#include <wx/wx.h>
#include <wx/intl.h>

class MyApp : public wxApp
{
    wxLocale m_locale;
public:
    bool OnInit() override
    {
        wxLog::AddTraceMask("i18n");

        m_locale.Init();
        m_locale.AddCatalog("wxstd");
        m_locale.AddCatalog("test");

        wxLogMessage(_("Test"));
        return false;
    }
}; wxIMPLEMENT_APP(MyApp);
produces this

Code: Select all

warning: (i18n) adding 'en_US' translation for domain 'wxstd-3.1' (msgid language 'en_US')
warning: (i18n) looking for "wxstd-3.1.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US.WINDOWS-1252\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US.WINDOWS-1252
warning: (i18n)
warning: (i18n) looking for "wxstd-3.1.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US
warning: (i18n)
warning: (i18n) looking for "wxstd-3.1.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en
warning: (i18n)
warning: (i18n) adding 'en_US' translation for domain 'wxstd' (msgid language 'en_US')
warning: (i18n) looking for "wxstd.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US.WINDOWS-1252\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US.WINDOWS-1252
warning: (i18n)
warning: (i18n) looking for "wxstd.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US
warning: (i18n)
warning: (i18n) looking for "wxstd.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en
warning: (i18n)
warning: (i18n) adding 'en_US' translation for domain 'test' (msgid language 'en_US')
warning: (i18n) looking for "test.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US.WINDOWS-1252\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US.WINDOWS-1252
warning: (i18n)
warning: (i18n) looking for "test.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en_US
warning: (i18n)
warning: (i18n) looking for "test.mo" in search path:
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en\LC_MESSAGES
warning: (i18n)     c:\dev\cb-tests\test200s\bin\en
warning: (i18n)
warning: (i18n) string "Test" not found in locale 'en_US'.
warning: (i18n) string "%s Information" not found in locale 'en_US'.
warning: (i18n) string "Yes" not found in locale 'en_US'.
warning: (i18n) string "No" not found in locale 'en_US'.
warning: (i18n) string "OK" not found in locale 'en_US'.
warning: (i18n) string "Cancel" not found in locale 'en_US'.
warning: (i18n) string "Help" not found in locale 'en_US'.
warning: (i18n) string "OK" not found in locale 'en_US'.
Catalogs are loaded properly.
Since I added warning messages to my program based on what I saw on internat samples
El_isra
Experienced Solver
Experienced Solver
Posts: 50
Joined: Tue Apr 13, 2021 1:10 am
Location: Buenos Aires, Argentina
Contact:

Re: Translate Program

Post by El_isra »

I DID IT!!!
it seems that i forgot to add

Code: Select all

: m_locale(locale)
after constructor parameters.

so, Doublemax Lied.
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Translate Program

Post by doublemax »

El_isra wrote: Mon Jun 14, 2021 3:27 pm so, Doublemax Lied.
About what?
Use the source, Luke!
Post Reply