You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, September 28th 2004, 9:35am

Cant Translate

hi,
Sorry for my poor English.
I am using kdevelop3.0.3 on Red Hat 9.0. I include the "kmmanager.h" to use the printing function in my program, and it works well. But I find it could not be translated to the language that I need (I have used linguist which works well in other parts of my program). Can any one help me?
Thanks in advance!

Regards,

e8johan

Beginner

Posts: 27

Location: Sweden

  • Send private message

2

Tuesday, September 28th 2004, 12:04pm

RE: Cant Translate

You will have to be more specific. In what situation cant you locate the language?

3

Wednesday, September 29th 2004, 7:02am

To be more clear

e8johan,
Sorry for not being clear because of my lack of English. What I mean in the thread is: I include the "kmmanager.h" in the file so I can initialize and show a printer management dialog where I need in the program. The problem is the dialog is always in its English version even I am in Chinese version of RedHat(for example). I can use the linguist tool to translate the UI of my program to Chinese, and it shows as I suppose when I am in chinese environment. But as for the management dialog it always shows in English, it seems I cant control the language it use.
Is that clear enough? Hope you could understand what I mean.
Anyway, thank you very much for replying !

Regards,

4

Wednesday, September 29th 2004, 7:10am

Absent for some days

I gonna be absent for holidays. For sure I will be back after a week.
Any reply is welcomed.

e8johan

Beginner

Posts: 27

Location: Sweden

  • Send private message

5

Wednesday, September 29th 2004, 7:14am

RE: To be more clear

Ok, so the Qt dialogs wont localize.

Do you use QTranslator to load the language in your main routine as described in the docs?

Could the problem be that the dialog uses the KDE language (as opposed to your application's language) and that it is not set to Chinese?

6

Wednesday, September 29th 2004, 8:35am

kde translation

As what you have pointed out, the "kmmanager.h" and many other files with the prefix 'k' are not really QT class head files but KDE head files. Then the question is "is it possible to translate the KDE class at run time. The situtation is when I call the dialog on the command line in the shell in my Chinese system, the dialig really shows in Chinese, but when I do the same thing in my application, it dose appear in English.
I have ever load the "qt_de.qm" file found under "/usr/lib/qt-3.3/translation"(there is on Chinese counterpart) at the runtime of my application for a test. The result is the QT class such as QFileDialog dose appear in its German version, but the printer management dialog I need still in English. Faint ~~~,how could it be that !
I have also tried to find the "qm" file used by KDE class,only to fail.
In fact , I am totally loss at sea now.

e8johan

Beginner

Posts: 27

Location: Sweden

  • Send private message

7

Wednesday, September 29th 2004, 9:14am

RE: kde translation

The problem seems to be related to the fact that the dialogs are from KDE (since the Qt equivalents are translated) so I moved the thread.

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

8

Wednesday, September 29th 2004, 12:09pm

When a program uses KDE classes, it is a KDE program.
Which also means it will use KDE's translation mechanism and translation files.

Maybe the program is setting a QTranslator object and this interferes with the KDE translation mechanism.

Anyway: where does this kmmanager.h come from? I thought that one had to include kprinter.h when using kprint framework

Cheers,
_
Qt/KDE Developer
Debian User

9

Thursday, October 7th 2004, 4:09am

to anda_skoa

I really include kprinter.h too. Maybe you could find the kmmanager.h under /usr/include/kde/kdeprint, the head file use kdeprint and kdeprint_management lib. Then what is the "KDE translation mechanism"? Can any one give me some materials or links that can explain it?

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

10

Thursday, October 7th 2004, 6:43pm

RE: to anda_skoa

Quoted

Originally posted by ecust-imp
I really include kprinter.h too. Maybe you could find the kmmanager.h under /usr/include/kde/kdeprint, the head file use kdeprint and kdeprint_management lib.

So what do you need that for?
kmmanager.h is an internal header of kprint, I see no reason why you would need it (unless you are a KDE Print developer :) )

Quoted


Then what is the "KDE translation mechanism"? Can any one give me some materials or links that can explain it?


You mark user visible strings with i18n() instead of tr(). Usually KDevelop generated application templates do this already at some places for example strings.
(I think it is declared in klocale.h)

Cheers,
_
Qt/KDE Developer
Debian User

11

Friday, October 8th 2004, 2:53am

where I use KMManager

The following is quoted from my group's application code.
void MainWindow::slotAddPrinterWizard()
{
KMManager::self()->addPrinterWizard();
}
This slot is connected to a button's click signal, so every time I click the button, an add printer wizard dialog appears. It seems I have to do so if I want to realize this fuction. I find the dialog is always in English, which puzzles me.
Is there another way in which I can complete the same function?

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

12

Friday, October 8th 2004, 3:04pm

Well, depends.
I thought that this is a normal user application, in which case you don't have to call anything from internal headers (which might change at any time as stated in the header file itself)

Of course if you are a KDE Print developer, for example working on a new printer configuration application, then this might be ok.

However my guess is that this is case one, a normal application, so the questions is why do you want to call something not intendend for this type of applications?

An application usually only need KPrinter, maybe KPrintDialogPage in case it wants some custom printing option in the print dialog.

Cheers,
_
Qt/KDE Developer
Debian User

13

Saturday, October 9th 2004, 2:42am

what should I do then?

The type of the application is a normal one, and most of the classes involved are QT class. I know there is QPrinter and KPrinter class I can use. The problem is I need to provide an easy way to let the user add a printer rather than using command line or the web service(open the browser and type localhost:631), so I think the add printer wizard is the best choice. I don't know whether you'v tried my code on your machine.
I found the code can work well. If the header is not intended for normal use, how can I compromise?

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

14

Tuesday, October 12th 2004, 12:25pm

The KPrinter configuration dialog already provides a button to invoke the printer wizard.

Cheers,
_
Qt/KDE Developer
Debian User

15

Wednesday, October 13th 2004, 2:30am

then how to internationalize?

Thank you for reminding me of this, now I could use the button in the KPrinter dialog to invoke the printer wizard as a substitution. The dialog is a common one that almost every KDE application uses as a interface when user clicks the print button.
Following is the code in my application where I call the dialog. It's very simple.
#include <kprinter.h>
void FileMainWindow::printFile()
{
KPrinter* printer = new KPrinter();
if (printer->setup(this)
{
......
}

}
My OS is redhat 9.0. I use its Chinese version. When I call the dialog in KDE's own application for example KDevelop, it appears to be in Chinese. When I call it in my application as shown above, it's always in English. How to change this?(I could do this if I use QT class instead of KDE class.)

djanubis

Beginner

Posts: 29

Location: Moulins France

Occupation: Software ingeneering

  • Send private message

16

Wednesday, October 13th 2004, 7:27am

RE: then how to internationalize?

Your problem could be that KDE uses the classic Unix internationalization system (po, mo and pot files) while your Qt app uses Qt multiplatform Linguist method.
Might be your app could use KDE translation system if it is only intended to run on Unix.
Never patch not working code. Rewrite it !
Never patch badly designed classes. Recreate them cleanly.
(Excerpts from Computing Bible)

Home of the Lab project

17

Wednesday, October 13th 2004, 8:41am

things listing

From the very beginning of working, the application was designed to be a totally QT one. It only contained QT class until we found the printing fuction QPrinter can give was limited. So we decided to use KPrinter as the main class with CUPS support as it comes with printing fuction.
In that case, you could think it to be a KDE app with QT class in it.
I have read materials about QT translation which I have said in the posts and it seems to work well. The only problem is I can't find Chinese qm file in /usr/lib/qt-3.3/translation as a translation support for all QT class, and the QTranslator object seems not to be able to load two qm file at once(one is the file I created for the app's UI, another is the one I should find in the above directory). Did I do something wrong?
Till now, I am not sure whether it is a KDE app with QT class or QT app with KDE class. Could it be designed like this? And what is the KDE translation system, can any one give me some links to that concept? I find nearly nothing about it on internet, I need information in detail which can teach me step by step for I am really a newbie in this field.
I find a lot of mo file in /usr/share/locale, how to use that? It seems they are used by the OS and not for the application designer.
Thank you very much!

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

18

Wednesday, October 13th 2004, 8:53pm

Use any KDE application source as an example, or one of the KDE application templated of KDevelop.

Basically all user visible strings are marked with i18n() instead of tr(), the makefile can extract and merge the messages into a .po file, which can be copied and translated.
A tool then generates translation catalogue files (.mo)

Description of the translation process for example on the KDE translators web site http://i18n.kde.org/
(especially for setups with non-latin languages like Asian languages it might be helpful to contact the KDE translation team for your own language, they might have some tips for you)

The base for this is the GNU gettext framework, used by most free software project that need internationalized output.

Anyway, if your other KDE applications appear correctly, do they so if started the same way as your application?
I mean if you start your application from commandline for testing, does a KDE application started from commandline hav correct translations?

Cheers,
_
Qt/KDE Developer
Debian User

19

Thursday, October 14th 2004, 2:20am

A KDE application started from commandline does have correct translations. The same thing happened to the UI of my application but not the KDE classes I used in it.
Anyway, I will first read the documentation on the website. Thank you very much!