Page 2 of 3
Re: Multilingual application
Posted: Thu Mar 16, 2017 6:36 pm
by Nucleorion
I also try:
Code: Select all
m_locale.Init(wxLANGUAGE_ENGLISH, wxLOCALE_CONV_ENCODING); //wxLOCALE_CONV_ENCODING Deprecated
wxLocale::AddCatalogLookupPathPrefix(wxT(".\\langs"));
m_locale.AddCatalog(wxT("es_ES"));
But it does not work either
Re: Multilingual application
Posted: Thu Mar 16, 2017 7:39 pm
by doublemax
Try a tool like Procmon and check in which paths the executable is looking for the translation files.
I use my own translation solution for my own texts, but for the wxWidgets translation files, i had to put them in this path:
Re: Multilingual application
Posted: Fri Mar 17, 2017 9:50 am
by Nucleorion
Procmon = Process monitor?
I get this:
Re: Multilingual application
Posted: Fri Mar 17, 2017 11:19 am
by PB
You may also check the output of the i18 debug trace, which shows the looked-up paths and files, as described here
viewtopic.php?f=1&t=42414#p171997
Re: Multilingual application
Posted: Fri Mar 17, 2017 12:04 pm
by doublemax
ProcMon:
https://technet.microsoft.com/en-us/sys ... nitor.aspx
Add a filter so that it only displays output for your exe and let it show only file events. You will still get hundreds of events when you start your app.
Re: Multilingual application
Posted: Fri Mar 17, 2017 8:28 pm
by eranon
Hello,
In my own codes, I manage location of the language catalogs like this:
Code: Select all
#ifdef __WXMSW__
#ifdef _DEBUG
m_strLangsBase = ::NormalizePathSep(wxPathOnly(argv[0]) + "/../../lang");
#else
m_strLangsBase = ::NormalizePathSep(wxPathOnly(argv[0]) + "/lang");
#endif
#endif // __WXMSW__
#ifdef __WXOSX__
m_strLangsBase = ::NormalizePathSep(wxPathOnly(argv[0]) + "/../Resources");
#endif // __WXOSX__
Also, just an added info on a secondary point : as stated at
http://docs.wxwidgets.org/trunk/group__ ... 96ec864160, I quote:
Note that since wxWidgets 2.9.0 you shouldn't use wxT() anymore in your program sources (it was previously required if you wanted to support Unicode).
It's now implicit.
Re: Multilingual application
Posted: Mon Apr 24, 2017 8:53 am
by Nucleorion
I keep trying
I have made sure that the files are on the path but it still does not work
It would be ideal to find a turorial updated and explained in detail. I really do not understand how with the work that it costs to make these tools then there is hardly official documentation
About the routes it can not find I do not understand why you ask for them. Nowhere have I seen that I have to create anything in a folder called LC_MESSAGES as well as many others
Re: Multilingual application
Posted: Mon Apr 24, 2017 10:17 am
by eranon
If you don't succeed with a relative path, go back to a known point and use an absolute harcoded one in your code for the moment. When all will be OK, you'll just have to fix this single point (since hardcoded absolute path is obviously not a good idea for your final release).
And to check if a file exists, you simply have wxFileExists() in stock.
Re: Multilingual application
Posted: Mon Apr 24, 2017 10:48 am
by doublemax
The ProcessMonitor output looks to me like the "es_ES" catalog is found. How do you check if it was successful?
Re: Multilingual application
Posted: Fri Apr 28, 2017 8:23 am
by Nucleorion
eranon wrote:If you don't succeed with a relative path, go back to a known point and use an absolute harcoded one in your code for the moment. When all will be OK, you'll just have to fix this single point (since hardcoded absolute path is obviously not a good idea for your final release).
And to check if a file exists, you simply have wxFileExists() in stock.
How I use an absolute harcoded one?
How use wxFileExists() in this. I can't use for example
Code: Select all
wxFileExists(m_locale.AddCatalog(wxT("es_ES")))
doublemax wrote:The ProcessMonitor output looks to me like the "es_ES" catalog is found. How do you check if it was successful?
I don't understand doublemax. I don't know how check it. ProcessMonitor says some routes found and others not. What path are the right? All?
Re: Multilingual application
Posted: Fri Apr 28, 2017 9:34 am
by Nucleorion
Whell, first error:
Code: Select all
m_locale.Init(wxLANGUAGE_SPANISH);//Init to the spanish
wxLocale::AddCatalogLookupPathPrefix(wxT(".\\langs"));//add path
m_locale.AddCatalog( wxT ("es"));//add catalog wxWidgetspath/locale/es.mo
m_locale.AddCatalog(wxT("es_ES"));//add my .mo edit files
Move this lines before //(*AppInitialize
So
Code: Select all
m_locale.Init(wxLANGUAGE_SPANISH);//Init to the spanish
wxLocale::AddCatalogLookupPathPrefix(wxT(".\\langs"));//add path
m_locale.AddCatalog( wxT ("es"));//add catalog wxWidgetspath/locale/es.mo
m_locale.AddCatalog(wxT("es_ES"));//add my .mo edit files
//(*AppInitialize
bool wxsOK = true;
wxInitAllImageHandlers();
if ( wxsOK )
{
MultilingualExampleFrame* Frame = new MultilingualExampleFrame(0);
Frame->Show();
SetTopWindow(Frame);
}
//*)
Now load the default language right. The path is: lang\es_ES\es_ES.mo
Re: Multilingual application
Posted: Fri Apr 28, 2017 9:44 am
by Nucleorion
For change language into to program I have a menu to set language.
Code: Select all
void MultilingualExampleFrame::OnMenu_Language_Spanish_Selected(wxCommandEvent& event)
{
wxLocale* locale;
long language=wxLANGUAGE_SPANISH;
locale = new wxLocale( language );
locale->AddCatalogLookupPathPrefix(wxT(".\\langs\\es_ES"));
locale->AddCatalog( wxT ("es_ES.po"));
}
This change texts of parents windows but no in the main frame; menus, form, etc.
How I can set language in runtime?
Re: Multilingual application
Posted: Fri Apr 28, 2017 11:53 am
by doublemax
How I can set language in runtime?
You can't - at least not with little effort. Store the new language, tell the user the app needs a restart and restart. As this doesn't happen often, i think it's an acceptable compromise.
Re: Multilingual application
Posted: Fri Apr 28, 2017 4:01 pm
by Nucleorion
Ok. Thanks Mate
Re: Multilingual application
Posted: Fri Apr 28, 2017 8:24 pm
by ONEEYEMAN
Also keep in mind that sometimes additional software might be required to properly display international symbols.
Or just a properly generated locale on the system.
Thank you.