Page 1 of 1

AddCatalog in OSX 10.15.7

Posted: Sat Jun 19, 2021 12:17 pm
by raananb
An application which used to work correctly, recently stopped translating.

I tried the sample of wxWidgets-3.1.5, and it works as expected.

To try and understand, I used the code below, based on the sample. It works for Windows & Linux, but in OSX the catalog is not loaded: AddCatalog returns 'false'. The 'translate.mo' file is in the standard location, i.e. 'Translate.app/Contents/Resources/French.lproj/translate.mo'

I use DialogBlocks with g++ on OSX and Poedit 2.4.2 (6064) on windows to produce 'translate.mo'.

I could not find why this happens. Could it be that my 'translate.mo' file is not accepted as legitimate under OSX? (it is with Windows & Linux Mint19)

Any light?

Code: Select all

void Translate::Init()
{
#ifdef __WXMSW__
   
  m_locale = new wxLocale;
  m_locale->Init();
  m_locale->AddCatalogLookupPathPrefix(".");
  m_locale->AddCatalog("translate");

#elif defined __WXMAC__

  m_locale = new wxLocale();  
  m_locale->Init();
  m_locale->AddCatalog("translate");
        
#else
     
    m_locale = new wxLocale;
    m_locale->Init();
    m_locale->AddCatalogLookupPathPrefix(".");
    m_locale->AddCatalog("translate");    
#endif
}


Re: AddCatalog in OSX 10.15.7

Posted: Sat Jun 19, 2021 4:58 pm
by ONEEYEMAN
Hi,
How is this failing?
Can you build the debug version of the library and application and step inside the function to see where it fails? And what the problem is?

Thank you.

Re: AddCatalog in OSX 10.15.7

Posted: Sun Jun 20, 2021 1:04 pm
by raananb
My messages are translated using Poedit from French to English.

My code:

Code: Select all

    
  wxLog::AddTraceMask("i18n");
    
  ret = m_locale = new wxLocale();
 
  ret = m_locale->Init();
        
  ret = m_locale->AddCatalog("mycatalog");
    
  wxMessageBox(_("hello"));

  wxMessageBox(_("File"));

AddCatalog not only does not find 'mycatalog', it also does not find 'wxstd' as shown below.

Last login: Sun Jun 20 14:29:55 on ttys000
raananbarzel@Mini-de-Raanan ~ %
raananbarzel@Mini-de-Raanan ~ %
raananbarzel@Mini-de-Raanan ~ % lldb /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app
(lldb) target create "/Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app"
Current executable set to '/Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app' (x86_64).
(lldb) r
Process 66592 launched: '/Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/MacOS/MyTrad' (x86_64)
14:56:05: Trace: (i18n) adding 'fr_FR' translation for domain 'wxstd-3.1' (msgid language 'en_US')
14:56:05: Trace: (i18n) looking for "wxstd-3.1.mo" in search path:
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.MacRoman.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.MacRoman.lproj
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.MacRoman/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.MacRoman
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.MacRoman.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.MacRoman.lproj
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.MacRoman/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.MacRoman
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) looking for "wxstd-3.1.mo" in search path:
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.lproj
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.lproj
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) looking for "wxstd-3.1.mo" in search path:
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr.lproj
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) /usr/local/share/locale/fr.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr.lproj
14:56:05: Trace: (i18n) /usr/local/share/locale/fr/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) Catalog "wxstd-3.1.mo" not found for language "fr_FR".
14:56:05: Trace: (i18n) adding 'fr_FR' translation for domain 'wxstd' (msgid language 'en_US')
14:56:05: Trace: (i18n) looking for "wxstd.mo" in search path:
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.MacRoman.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.MacRoman.lproj
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.MacRoman/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.MacRoman
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.MacRoman.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.MacRoman.lproj
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.MacRoman/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.MacRoman
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) looking for "wxstd.mo" in search path:
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.lproj
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.lproj
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) looking for "wxstd.mo" in search path:
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr.lproj
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) /usr/local/share/locale/fr.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr.lproj
14:56:05: Trace: (i18n) /usr/local/share/locale/fr/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) Catalog "wxstd.mo" not found for language "fr_FR".
14:56:05: Trace: (i18n) adding 'fr_FR' translation for domain 'mycatalog' (msgid language 'en_US')
14:56:05: Trace: (i18n) looking for "mycatalog.mo" in search path:
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.MacRoman.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.MacRoman.lproj
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.MacRoman/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.MacRoman
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.MacRoman.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.MacRoman.lproj
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.MacRoman/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.MacRoman
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) looking for "mycatalog.mo" in search path:
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.lproj
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR/LC_MESSAGES
14:56:05: Trace: (i18n) /Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.lproj/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR.lproj
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR/LC_MESSAGES
14:56:05: Trace: (i18n) /usr/local/share/locale/fr_FR
14:56:05: Trace: (i18n)
14:56:05: Trace: (i18n) Using catalog "/Users/raananbarzel/ProjetsDB/MyTradApp/OSXDebug/MyTrad.app/Contents/Resources/fr_FR.lproj/mycatalog.mo".
14:56:05: Trace: (i18n) string "hello" not found in locale 'fr_FR'.
14:56:05: Trace: (i18n) string "No" not found in locale 'fr_FR'.
14:56:05: Trace: (i18n) string "Yes" not found in locale 'fr_FR'.
14:56:05: Trace: (i18n) string "OK" not found in locale 'fr_FR'.
14:56:05: Trace: (i18n) string "Cancel" not found in locale 'fr_FR'.
14:56:11: Trace: (i18n) string "File" not found in locale 'fr_FR'.
14:56:11: Trace: (i18n) string "No" not found in locale 'fr_FR'.
14:56:11: Trace: (i18n) string "Yes" not found in locale 'fr_FR'.
14:56:11: Trace: (i18n) string "OK" not found in locale 'fr_FR'.
14:56:11: Trace: (i18n) string "Cancel" not found in locale 'fr_FR'.
Process 66592 exited with status = 0 (0x00000000)
(lldb)

Re: AddCatalog in OSX 10.15.7

Posted: Sat Jun 26, 2021 1:44 pm
by raananb
Changing 'French.lproj', to 'fr.lproj' or to fr_FR.lproj' in the .app folder (without modifying the program code) solved the problem, coherent with the lookup mechanism to locate the catalog.

However, this does not explain why a different application, compiled under the same environment, gets the expected translation with the catalog in 'French.lproj' folder.

Re: AddCatalog in OSX 10.15.7

Posted: Sat Jun 26, 2021 3:03 pm
by ONEEYEMAN
Hi,
What do you mean? How many other applications did you build? How many uses wxWidgets? What version?

Thank you.

Re: AddCatalog in OSX 10.15.7

Posted: Sat Jun 26, 2021 8:36 pm
by raananb
What I mean is very clear: in half a dozen applications French.lproj works, whether compiled now, that is with 3.1.5 or earlier.

On one specific application 'French.lproj' must be renamed to 'fr.lproj' or to 'fr_FR.lproj' for translation to take place. A version of this application built in April 2021 functions fine with 'French.lproj'.

I have no explanation for this difference. I just wanted to signa this behavior and a way to overcome the problem.

Thank you for your interest.

Re: AddCatalog in OSX 10.15.7

Posted: Sun Jun 27, 2021 1:28 am
by ONEEYEMAN
Hi,
Can you try to run this application under debugger and see what causes that failure?
Also, how do you initialize i18n wxWidgets system? Where is this file located and are you sure it is there?

You can also try to run the application with:

WXTRACE="i18n" open myapp.app

and compare the logging for both apps.

Something is very different here.

Thank you.

Re: AddCatalog in OSX 10.15.7

Posted: Sun Jun 27, 2021 11:40 am
by raananb
I rewrote a simple app (MyTrad) with the following code related to wxLocale:

m_locale = new wxLocale();
m_locale->Init(wxLANGUAGE_FRENCH);
m_locale->AddCatalog("mycatalog");

I then created three folders in Resources folder of MyTrad.app and copied mycatalog.mo into each folder in succession:

fr.lproj
fr_FR.mproj
French.lproj

The translation works when the catalog is in 'fr.lproj' or in 'fr_FR.lproj', but not when in 'French.lproj'

My conclusion is that 'French.lproj' was accepted in older applications because they contained explicit locale path for this folder, due mainly to my inexperience at the time with wxLocale.

I guess that solves the problem.