Multilingual application
- Nucleorion
- Knows some wx things
- Posts: 45
- Joined: Sat Jan 07, 2017 10:08 pm
Multilingual application
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
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
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
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
Use the source, Luke!
Re: Multilingual application
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.
Did you try the internat sample?
Also, make sure you put you translation files into the directory where they can be found.
Thank you.
- Nucleorion
- Knows some wx things
- Posts: 45
- Joined: Sat Jan 07, 2017 10:08 pm
Re: Multilingual application
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
I cant find strings with poedit to fill .po or create .pot file
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"
-
- Filthy Rich wx Solver
- Posts: 235
- Joined: Fri Sep 14, 2012 8:26 am
- Location: Kontich, Belgium
- Contact:
Re: Multilingual application
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.
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.
- Nucleorion
- Knows some wx things
- Posts: 45
- Joined: Sat Jan 07, 2017 10:08 pm
Re: Multilingual application
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?
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
Hi,
Did you run the "internat" sample?
Also, the default language is determined by locale.
Thank you.
Did you run the "internat" sample?
Also, the default language is determined by locale.
Thank you.
Re: Multilingual application
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
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.
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.
- eranon
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
- Contact:
Re: Multilingual application
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.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?
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.
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
Re: Multilingual application
Actually, I have never used it but wxWidgets do directly support .mo files embedded into the executable, at least on MS Windows:ONEEYEMAN wrote:Embed the translation is not possible, you will have to distribute separate files.
http://docs.wxwidgets.org/trunk/classwx ... oader.html
- Nucleorion
- Knows some wx things
- Posts: 45
- Joined: Sat Jan 07, 2017 10:08 pm
Re: Multilingual application
Thank you very much!
- Nucleorion
- Knows some wx things
- Posts: 45
- Joined: Sat Jan 07, 2017 10:08 pm
Re: Multilingual application
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
In MyApp.cpp in bool MultilingualExampleApp::OnInit()
but when I run my app the language is not changed
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;
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
Re: Multilingual application
As Oneeyeman suggested, follow "internat" sample. See the differences to your code.