[SOLVED] i18n and linguist questions
-
Hi
Trying to learn how to do i18n the QT way.
Using sample
Qt-5.3\widgets\tools\i18n- When I open a TS file with linguist .exe
It ask which source and target. (in a small dialog)
So it has no idea what language the file actually contains?
If I choose wrong, will it damage the file?One option for language is POSIX.
Which means c locale ? or how to read that.- In this sample, it shows a dialog that change language for the main window.
I then changed the a button text in this Dialog from "show all" to tr("Show'em")
I ran the tools and my TS file now contains this new entry "Show'em". which i translated and
compiled new QM file.
BUT
When I load the language file, the button text never changes in the Dialog.
so my QUESTIONS are
Do I have to recreate the dialog to make it use new text or should it be dynamic ?
its uses
qApp->installTranslator(&translator);
so it seems to be app wide, so why is button not using translated text?
I assume that the "use translation" flag on widgets are on by default.
Thank you
- When I open a TS file with linguist .exe
-
Hi,
- these are only information about the contents. IMO you cannot damage the file
- You're right
- Is the .qm file part of applications resources? if YES you should rebuild the app because the translations are embedded into the application itself
Happy Translating
-
Hi
1: ok, its mostly just to show which correct label for
translation and not really important.3:
Yes, in this sample its part of a res.
I have cleaned and rebuild. It can load it.But The dialog's button does not change. so I guess i do not know if
it can be that dynamic. The dialog will create a new main window object when language changes.
The dialog is same object until app.exit. So I will need to delete and recreate the dialog before it can change language or
can it dynamic change in an object life span ?so I guess question is.
for an object. already created. can its texts be change without new(ing)it again ?thank you
-
@mrjj said:
or
can it dynamic change in an object life span ?You can handle language change at runtime using this example
void Widget::changeEvent(QEvent *e) { QWidget::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: ui->retranslateUi(this); break; default: break; } }
It works if you have a .ui file for the dialog
-
oh, that looks sort of promising.
In sample, (like most) no UI files is used. all code.
They seems to love doing it in code. :)I will browse the qt code and see what retranslateUi really does.
Thank you
Final question: Where is Resolved function hidden ?