Page 1 of 2

Internationalisation

Posted: Wed Oct 31, 2018 11:50 am
by gtafan
I took a look at the internationalisation sample, but it´s a bit complicated and confusing. I have mo file in the same directory as the applicaton, how can I tell the application to use that mo file?

Re: Internationalisation

Posted: Wed Oct 31, 2018 2:46 pm
by ONEEYEMAN
Hi,
Did you read the documentation?
Did you look at how the translation files are structured in the internat sample directory?
Did you try to debug what happens in the sample?

Thank you.

Re: Internationalisation

Posted: Thu Nov 01, 2018 11:14 am
by xaviou
Hi.

Do to this, you'll have to write your own wxTranslationsLoader as the default one can't do this.

You can have a look at this application as this is what it does : it looks in the same folder as the executable to see if a file named "language.mo" is present, and use it if it is the case.

Regards
Xav'

Re: Internationalisation

Posted: Thu Nov 01, 2018 2:12 pm
by PB
You probably also need to keep in mind that the wxWidgets catalog itself (wxstd) needs to be loaded. This is AFAIK done automatically by calling wxTranslations::AddStdCatalog() which in turn basically just calls AddCatalog(wxS("wxstd")).

Additionally, if there are not folders with language/locale names, how does the automatic selection of a catalog based on user's OS language work?

TBH, I see no need to store the catalogs in a non-standard way. The User does/should not care what is stored in the program's folder. if it is a portable app, it may be for the best to have only a launcher executable in app folder and all the actual files including the application executable in a subfolder...

Re: Internationalisation

Posted: Thu Nov 01, 2018 2:35 pm
by T-Rex
https://wxwidgets.info/wxtranslation/

It's for older versions of wxWidgets and may require soma minor changes in the source code, but gives the idea of how to make .mo files work in your app.

Re: Internationalisation

Posted: Thu Nov 01, 2018 4:27 pm
by gtafan
xaviou wrote:Hi.

Do to this, you'll have to write your own wxTranslationsLoader as the default one can't do this.

You can have a look at this application as this is what it does : it looks in the same folder as the executable to see if a file named "language.mo" is present, and use it if it is the case.

Regards
Xav'
What default wxTranslationsLoader can't do?

Re: Internationalisation

Posted: Thu Nov 01, 2018 5:20 pm
by xaviou
gtafan wrote: What default wxTranslationsLoader can't do?
Using a "mo" file placed in the same folder than the executable itself.
It was possible with wx-2.8.x, but not since wx-3.0.x (as I remember...)
PB wrote:You probably also need to keep in mind that the wxWidgets catalog itself (wxstd) needs to be loaded. This is AFAIK done automatically by calling wxTranslations::AddStdCatalog() which in turn basically just calls AddCatalog(wxS("wxstd")).
wxWidgets catalog can be merged with the application's one if needed.

Regards
Xav'

Re: Internationalisation

Posted: Fri Nov 02, 2018 2:23 pm
by gtafan
xaviou wrote:
gtafan wrote: What default wxTranslationsLoader can't do?
Using a "mo" file placed in the same folder than the executable itself.
It was possible with wx-2.8.x, but not since wx-3.0.x (as I remember...)
Xav'
OK, than I can place the mo file in some subfolder, so it maches.

Re: Internationalisation

Posted: Fri Nov 02, 2018 3:01 pm
by ONEEYEMAN
Hi,
Yes - just follow the directory structure of the internat sample.

Thank you.

Re: Internationalisation

Posted: Sun Nov 04, 2018 1:52 pm
by gtafan
ONEEYEMAN wrote:Hi,
Yes - just follow the directory structure of the internat sample.

Thank you.
I did folowed the structure, but how to let my application use the right language now? So let say the file with translations is called translations.mo and is in the folder lang, where lang is just a placeholder for any suported language.

Re: Internationalisation

Posted: Sun Nov 04, 2018 4:25 pm
by ONEEYEMAN
Hi,
You should have a set of directories for every language you plan to support. Is this the case?
Then just look at the internat sample and do what it does.

Thank you.

Re: Internationalisation

Posted: Mon Nov 05, 2018 11:31 am
by gtafan
ONEEYEMAN wrote:Hi,
You should have a set of directories for every language you plan to support. Is this the case?
Then just look at the internat sample and do what it does.

Thank you.
Yes I have a set of directories for every language I plan to support.
But internat sample is exactly the problem I started from, I am really unable to find out how the language is set in that code. It seems like it have to do with wxLocale, but that m_locale seems to be never used, so the code make no sence for me.

Re: Internationalisation

Posted: Mon Nov 05, 2018 2:42 pm
by ONEEYEMAN
Hi,
Is the sample works?
If yes - then you should do exactly the same in your code.

Thank you.

Re: Internationalisation

Posted: Mon Nov 05, 2018 4:09 pm
by gtafan
ONEEYEMAN wrote:Hi,
Is the sample works?
If yes - then you should do exactly the same in your code.

Thank you.
I think you are not understanding my problem, if I do exactly the same as in the sample, I´ll get just the sample application, which is useles for me.

Re: Internationalisation

Posted: Mon Nov 05, 2018 4:57 pm
by ONEEYEMAN
Hi,
Well, all you need to do is to get the code from the sample on how the initialization is performed and drop it into your own code.

Can you do that or you have trouble finding where it is being done?

Thank you.