Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 163
Registered: ‎01-30-2013
My Device: Blackberry 10 Simulator

Re: support different languages on blackberry 10

[ Edited ]

How should I specify it correctly??

 

it seems to not work when I added following line in my .pro file:

SOURCES += $$BASEDIR/src/App/MyProgram.cpp

 

 btw. About if my classes derive from QObject, some do, some don't but which don't that's why I use QObject::tr() function instead of tr()....

 

please help... it would be nice to get around this. Thanks.

 

EDIT: Aha, it seems to work now: I added following line instead of what I wrote above:

 

lupdate_inclusion {
    SOURCES += \
        $$BASEDIR/../src/App/*.cpp $$BASEDIR/../assets/*.qml
}

 

ps. This is how my ts file looks like:

 

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="en_US">
<context>
    <name>QObject</name>
    <message>
        <source>justNow</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <source>oneMinuteAgo</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <source> minutes ago</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <source>oneHourAgo</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <source> hours ago</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>MyProgram</name>
    <message>
        <source>hello</source>
        <translation type="unfinished"></translation>
    </message>
</context>
</TS>

 The only thing I don't like is the: <name>QObject</name> for one of my .cpp file translations - am I free to rename it, and give the name of the appropriate class for example? from which the keywords originiate.

 

and final thing: how do I select which language to use??? e.g., _en or _de file for example?? Thank you.

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: support different languages on blackberry 10

you should not edit the ts files manually, as they are created.

you can add a context note in tr() by using a second string, like tr("to translate", "comment")

use QtLinguist to do the translation, its easy to use.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 163
Registered: ‎01-30-2013
My Device: Blackberry 10 Simulator

Re: support different languages on blackberry 10

OK, I thought I could at least input the translation strings in the ts files... seems no?? Ok, I will look into QtLinguist...

just that: <name>QObject</name> was concerning be, because the keywords in that section are from one particular .cpp file, seems all other .cpp files that need translation will also be named as <name>QObject</name> ?? Thanks.
Highlighted
Developer
Posts: 115
Registered: ‎10-22-2012
My Device: Developer
My Carrier: Mobifone

Re: support different languages on blackberry 10

[ Edited ]

You must add the correct relative path to all of your source file that contains string which needed to localized. So, if you put your source file in the sub-folder of the src folder, you must add them to the path.
You can select which language to use by editing bar-description.xml, tab Localization.

About the name of the Context, I see that context's name is the same as class's name or the name of QML file, I don't think you can change it.



Like my answer if it's helpful. Mark as answer if it help you solve the problem.
New Developer
Posts: 167
Registered: ‎04-12-2010
My Device: Storm
My Carrier: Verizon

Re: support different languages on blackberry 10

I know somewhere in that documentaion is the way to do it, but I thought you guys are trying to get more devs to it rather than make life more complicated , in most other IDEs you define a file per supported language with some sort of a tag per sentence, add the translation for it and be done with it. The tags are used as aliases of the sentence

 

I've been going the way of the initiator if this thread and have yet to make sense out of it, the documentation states how easy is to do this you can have this and that, but they dont tell u how to set it up??? Not sure if I'm right but so far it looks like for every source file it will add entries to the .ts , but lots of these strings like ARE_YOU_SURE are used across different files will that have to be repeated/translated for every source file????

 

  sorry for the rant something as simple as localize my App is getting me around loops still not working 4 me I'm about to just define my own set of XML files take that tr() out and forget about trying to make this one work.

Developer
Posts: 828
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: support different languages on blackberry 10

if there's multiple groups of the same text, they will need to each be given the proper translation for that language, but the plus side of that is they're the same so they will have the same answer = )  (**copy/paste**)

 

if you choose the languages you want to support in your bar descriptor under the localization tab, it will create the .ts for those languages & update your config.pri to support them

 

I used google translate for my translations & QT linguist (download) to modify the .ts files which made things much easier

 

 

New Developer
Posts: 167
Registered: ‎04-12-2010
My Device: Storm
My Carrier: Verizon

Re: support different languages on blackberry 10

Global replacement would do but still a pain as some sub-phrase might get caught. I don't see the gain of doing that.

 

Be careful with google translator,  english is my 3rd language,  I do use  the g-translator for my better languages just as a reference since  I see statements come out wrong for a native speaker the message will be fine but not right

like if I'd say to you "it are a good day"  some may come even worse I'd say at best 60% is OK and goes down from there