This forum has been archived. All content is frozen. Please use KDE Discuss instead.

how to translate my script ?

Tags: None
(comma "," separated)
thomas.dub
Registered Member
Posts
14
Karma
0

how to translate my script ?

Wed Mar 11, 2009 8:50 pm
Hello people,

For one of some final details of my script, I want to translate in some languages, French and English for starting.

Is it a simple way to do this ? using a file containing all messages in each languages, and with a system to choose the specified language in function of the default system language ?

Thanks for your help :)


Excuse my english.. please ;)
"Before, I had a life, now, I have a PC."
sven423
Registered Member
Posts
5
Karma
0

Re: how to translate my script ?

Wed Mar 11, 2009 9:18 pm
Getting the language might be possible with QLocale: http://doc.trolltech.com/4.5/qlocale.html

I think http://doc.trolltech.com/4.5/qobject.html#tr will not work, as we would need Subclasses of QObject for that... but with a known locale a simple translating system could relatively easy be built, I guess.
thomas.dub
Registered Member
Posts
14
Karma
0

Re: how to translate my script ?

Thu Mar 12, 2009 9:51 am
Thanks,

I think I will use this method :

In two separate .js files, containing all messages in each language (French and English)

And on my script, I just have to include the good file depending of the locale settings :

if (QLocale.system().country() == QLocale.France)
    Amarok.import("french_lang.js");
else
    Amarok.import("english_lang.js");
With the correct syntax for importing files (I don't remember).


Excuse my english.. please ;)
"Before, I had a life, now, I have a PC."
thomas.dub
Registered Member
Posts
14
Karma
0

Re: how to translate my script ?

Thu Mar 12, 2009 2:34 pm
It works great !

I've remplaced all strings in my main.js file by constants like "LANG_DEST_DIR".

And on my two languages files, I've defined all constants using "const LANG_DEST_DIR="Set destination dir"; "

And now, if I launch amarok using this syntax :
LANG=en_US.UTF-8 amarok
the script is in English
and if I use
LANG=fr_FR.UTF-8 amarok
the script is in French !

Thanks for your help sven423 :)


Excuse my english.. please ;)
"Before, I had a life, now, I have a PC."
User avatar
Ignacio Serantes
Registered Member
Posts
453
Karma
1
OS

Re: how to translate my script ?

Thu Mar 12, 2009 6:07 pm
Good, I'm looking for this.


Ignacio Serantes, proud to be a member of KDE forums since 2008-Nov.
thomas.dub
Registered Member
Posts
14
Karma
0

Re: how to translate my script ?

Fri Mar 13, 2009 2:09 pm
I've published an update containing this translating system
http://kde-apps.org/content/show.php/Sy ... ent=100841

There's a new way in QTScript 4.5 for internationalization : http://doc.trolltech.com/4.5/qtscript.h ... nalization
but I don't understand how it's works and on my Amarok Script Console, qsTr() and some others functions are not usable.


Excuse my english.. please ;)
"Before, I had a life, now, I have a PC."


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], daret, Evergrowing, Google [Bot], lockheed, sandyvee, Sogou [Bot]