Translation for qt based libraries
Hi,
I have to localize texts inside a library using qt. Setting up and using lupdate and lrelease from inside buildsystem works perfect.
But two questions:
1. Where I have to install the localized files so qt will find them? (Linux/Unix). For first I used /usr/share/<libname>/i18n/ as target folder.
2. How may I load this translations inside library? is this possible without knowledge about the calling application or has the application load the translation for this library?
Cu
E.
Re: Translation for qt based libraries
Quote:
Originally Posted by
elektritter
1. Where I have to install the localized files so qt will find them? (Linux/Unix). For first I used /usr/share/<libname>/i18n/ as target folder.
Anywhere you want - you'll tell Qt where to look for them when requesting the translations. You can even embed the translations into the library itself.
Quote:
2. How may I load this translations inside library? is this possible without knowledge about the calling application or has the application load the translation for this library
You can either do that yourself or tell the end-developer to do that. In either case you have to make sure QApplication object is already created and then you need to install a translator on it. You can create a kind of "initialize" function that the end-developer will have to call and that would install the translator.
Re: Translation for qt based libraries
Quote:
Originally Posted by
wysota
Anywhere you want - you'll tell Qt where to look for them when requesting the translations. You can even embed the translations into the library itself.
A - and how do I qt tell this? I looked trough documentation but didn't see any point "Load translations from this location".
And embedding into application is made via a rc-file if I read the documentation right at this point. So Same: how do I embed it into a library? Loading a rc-file makes no sense to me. (If you may point me to the right documentation would be real nice)
Quote:
You can either do that yourself or tell the end-developer to do that. In either case you have to make sure QApplication object is already created and then you need to install a translator on it. You can create a kind of "initialize" function that the end-developer will have to call and that would install the translator.
Ok, constructor of main interface looks like a good idea for this...
tnx for you answer
E.
Re: Translation for qt based libraries
Quote:
Originally Posted by
elektritter
A - and how do I qt tell this? I looked trough documentation but didn't see any point "Load translations from this location".
QTranslator::load()
Quote:
And embedding into application is made via a rc-file if I read the documentation right at this point. So Same: how do I embed it into a library? Loading a rc-file makes no sense to me. (If you may point me to the right documentation would be real nice)
What do you mean that it makes no sense to you?