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
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Wed Mar 29, 2017 9:52 am

Internationalisation

Post by gtafan » Wed Oct 31, 2018 11:50 am

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: 3607
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Internationalisation

Post by ONEEYEMAN » Wed Oct 31, 2018 2:46 pm

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: 429
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: Internationalisation

Post by xaviou » Thu Nov 01, 2018 11:14 am

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 : [email protected]'s wxStuff

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2094
Joined: Sun Jan 03, 2010 5:45 pm

Re: Internationalisation

Post by PB » Thu Nov 01, 2018 2:12 pm

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: 1185
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Re: Internationalisation

Post by T-Rex » Thu Nov 01, 2018 2:35 pm

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
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Wed Mar 29, 2017 9:52 am

Re: Internationalisation

Post by gtafan » Thu Nov 01, 2018 4:27 pm

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: 429
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: Internationalisation

Post by xaviou » Thu Nov 01, 2018 5:20 pm

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 : [email protected]'s wxStuff

gtafan
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Wed Mar 29, 2017 9:52 am

Re: Internationalisation

Post by gtafan » Fri Nov 02, 2018 2:23 pm

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: 3607
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Internationalisation

Post by ONEEYEMAN » Fri Nov 02, 2018 3:01 pm

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

Thank you.

gtafan
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Wed Mar 29, 2017 9:52 am

Re: Internationalisation

Post by gtafan » Sun Nov 04, 2018 1:52 pm

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: 3607
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Internationalisation

Post by ONEEYEMAN » Sun Nov 04, 2018 4:25 pm

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
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Wed Mar 29, 2017 9:52 am

Re: Internationalisation

Post by gtafan » Mon Nov 05, 2018 11:31 am

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: 3607
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Internationalisation

Post by ONEEYEMAN » Mon Nov 05, 2018 2:42 pm

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

Thank you.

gtafan
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Wed Mar 29, 2017 9:52 am

Re: Internationalisation

Post by gtafan » Mon Nov 05, 2018 4:09 pm

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: 3607
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Internationalisation

Post by ONEEYEMAN » Mon Nov 05, 2018 4:57 pm

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