Page 1 of 3

Multilingual application

Posted: Fri Feb 17, 2017 10:29 am
by Nucleorion
Any tutorial for implement multilinguan function.

I try with poedit follow this tutorial:
http://www.gsy-design.com/how-to-genera ... ng-poedit/

But they no find any string

I try also change parameter according to the page:
https://wiki.wxwidgets.org/Internationalization

thanks

Re: Multilingual application

Posted: Fri Feb 17, 2017 1:44 pm
by doublemax
Are your text literals wrapped in the _() macro?

Other than that, there really is not much that can go wrong.

Also, check the "official" wxWidgets page on that topic:
http://docs.wxwidgets.org/trunk/overview_i18n.html

Re: Multilingual application

Posted: Fri Feb 17, 2017 3:51 pm
by ONEEYEMAN
Hi,
Did you try the internat sample?
Also, make sure you put you translation files into the directory where they can be found.

Thank you.

Re: Multilingual application

Posted: Mon Feb 20, 2017 2:46 pm
by Nucleorion
Yes, I have _("Button") texts and tags of controls are generated with _() for codeblocks and wxwidgets.

I put .po and .mo files together .cpp files but I dont fill .po file, Only I have header.

en_US.po

Code: Select all

msgid ""
msgstr ""
"Project-Id-Version: rf2pl\n"
"POT-Creation-Date: 2017-02-17 10:57+0100\n"
"PO-Revision-Date: 2017-02-17 10:58+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.11\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: _(\n"
"X-Poedit-SearchPath-0: .\n"
I cant find strings with poedit to fill .po or create .pot file

Re: Multilingual application

Posted: Mon Feb 20, 2017 2:51 pm
by T-Rex

Re: Multilingual application

Posted: Mon Feb 20, 2017 8:19 pm
by Nunki
Why not take the xrc approach. With dialogblocks I create the GUI screens and let it create the xrc files instead of c++ code. I copy all these xml files into a ./xrc/nld or ./xrc/eng directory, depending on the language used. A language code associated with a login makes the application load the right xrc files, thus providing the screens in the right language.
Only for fixed texts, I use the database to store strings in several languages with an identifier. So they can be loaded at startup as well.
This approach gives you the ability that, though the pc may be in dutch or german, for example, when a user is french, at login his application wil run in his language.
And above all, your code stays the same, regardless.

Nunki.

Re: Multilingual application

Posted: Wed Feb 22, 2017 6:55 am
by Nucleorion
Thk for all :)

Finally I extract text setting _ how keyword for _("My text") and setting ‪xgettext --force-po -o %o %C %K %F in order for extraction.

I have already translated strings and I have created .po and .mo files.

But how do I now for the user to choose one language or another?

Re: Multilingual application

Posted: Wed Feb 22, 2017 7:08 am
by ONEEYEMAN
Hi,
Did you run the "internat" sample?
Also, the default language is determined by locale.

Thank you.

Re: Multilingual application

Posted: Tue Feb 28, 2017 12:29 am
by delt
I was meaning to also ask about this. I'm familiar with using gettext/libintl with non-wxWidgets projects, but how does it work with wxWidgets when it comes to redistributing/selecting .mo files? For example, is there a way to embed them in the executable, and not have to redistribute a whole directory structure for the locale stuff?

Re: Multilingual application

Posted: Tue Feb 28, 2017 1:05 am
by ONEEYEMAN
Hi,
Like I said, run the internat sample and then look at the code.
Embed the translation is not possible, you will have to distribute separate files.

Thank you.

Re: Multilingual application

Posted: Tue Feb 28, 2017 11:49 am
by eranon
delt wrote:I was meaning to also ask about this. I'm familiar with using gettext/libintl with non-wxWidgets projects, but how does it work with wxWidgets when it comes to redistributing/selecting .mo files? For example, is there a way to embed them in the executable, and not have to redistribute a whole directory structure for the locale stuff?
It depends on the operating system you target. On Mac for example, an app bundle (.app) is already a tree with directories and files inside, then you don't have to deploy any .mo outside of the bundle.

However, all mechanisms are always possible, even if it's not the standard. You can embed what you want in an executable (even an exe in an exe) and generate what file you want on disk when you decide: for example, generate the .mo from your app itself on the first launch... But, frankly, it's an added work while it's very easy to simply copy these .mo from your installer.

Re: Multilingual application

Posted: Tue Feb 28, 2017 1:43 pm
by PB
ONEEYEMAN wrote:Embed the translation is not possible, you will have to distribute separate files.
Actually, I have never used it but wxWidgets do directly support .mo files embedded into the executable, at least on MS Windows:
http://docs.wxwidgets.org/trunk/classwx ... oader.html

Re: Multilingual application

Posted: Tue Feb 28, 2017 3:41 pm
by Nucleorion
Thank you very much!

Re: Multilingual application

Posted: Thu Mar 16, 2017 12:34 pm
by Nucleorion
I like store translate files in folder .//langs

Then I have langs folder with mo and po files cuatriplicated for prevent wrong ubication
MyAppPath\es_ES.mo
MyAppPath\langs\es_ES.mo
MyAppPath\bin\langs\es_ES.mo
MyAppPath\bin\Debug\langs\es_ES.mo

I try follow the video https://wxwidgets.info/localization_video/

Then I type in MyApp.h

Code: Select all

        wxLocale m_locale; 
In MyApp.cpp in bool MultilingualExampleApp::OnInit()

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(_("es_ES"));//add my .mo edit files
	
but when I run my app the language is not changed

Re: Multilingual application

Posted: Thu Mar 16, 2017 5:14 pm
by Manolo
As Oneeyeman suggested, follow "internat" sample. See the differences to your code.