Internationalisation Topic is solved

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.
gtafan
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 201
Joined: Wed Mar 29, 2017 9:52 am

Internationalisation

Post 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?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Internationalisation

Post 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.
User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 437
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: Internationalisation

Post 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'
My wxWidgets stuff web page : X@v's wxStuff
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Internationalisation

Post 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...
User avatar
T-Rex
Moderator
Moderator
Posts: 1248
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Re: Internationalisation

Post 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.
gtafan
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 201
Joined: Wed Mar 29, 2017 9:52 am

Re: Internationalisation

Post 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?
User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 437
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: Internationalisation

Post 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'
My wxWidgets stuff web page : X@v's wxStuff
gtafan
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 201
Joined: Wed Mar 29, 2017 9:52 am

Re: Internationalisation

Post 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.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Internationalisation

Post by ONEEYEMAN »

Hi,
Yes - just follow the directory structure of the internat sample.

Thank you.
gtafan
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 201
Joined: Wed Mar 29, 2017 9:52 am

Re: Internationalisation

Post 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.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Internationalisation

Post 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.
gtafan
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 201
Joined: Wed Mar 29, 2017 9:52 am

Re: Internationalisation

Post 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.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Internationalisation

Post by ONEEYEMAN »

Hi,
Is the sample works?
If yes - then you should do exactly the same in your code.

Thank you.
gtafan
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 201
Joined: Wed Mar 29, 2017 9:52 am

Re: Internationalisation

Post 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.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Internationalisation

Post 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.
Post Reply