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
simon_hain
Posts: 15,956
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: support different languages on blackberry 10

make sure that the classes (or their folders) where you use tr() are in your SOURCES section
----------------------------------------------------------
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
Please use plain text.
Developer
gdev001
Posts: 163
Registered: ‎01-30-2013
My Device: Blackberry 10 Simulator

Re: support different languages on blackberry 10

[ Edited ]

Hi, what do you mean with SOURCES section? The one mentioned in the config.pri file of my project??? ps. by the way, does this translation process go always this "backwards" i.e., first I put keywords in my cpp files and corresponding entries are created in the .ts files??? Can't it be the other way around, e.g., I first add some keywords and their translations to the .ts files - and then I can use them in my source files??? Thanks.

Please use plain text.
Developer
simon_hain
Posts: 15,956
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: support different languages on blackberry 10

with SOURCES i mean the section in the pro file.

and yes, the translation goes this way. I usually write all texts in English within the app and add translations as needed.

maybe you can check out this session from the BB Jam in Amsterdam about localization:
http://hosting.desire2learncapture.com/RIM/1/watch/144.aspx
----------------------------------------------------------
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
Please use plain text.
Developer
gdev001
Posts: 163
Registered: ‎01-30-2013
My Device: Blackberry 10 Simulator

Re: support different languages on blackberry 10

Hi,

 

I actually have two .pro files in my project (I wanted to ask you about it, is it supposed to be like this? Both have same names; one is located in the "translations" folder and called MyProgram.pro and the other one I guess is the default one also MyProgram.pro).

 

and I don't see a SOURCES section in those .pro files either... ?!?!?!

 

thanks.

Please use plain text.
Developer
simon_hain
Posts: 15,956
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: support different languages on blackberry 10

the file in the translation folder is just a copy.

If i check the pro files of all the samples there is a HEADERS and a SOURCES section.

Maybe you should try to create your project with the wizard and/or check for differences to the sample projects.
----------------------------------------------------------
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
Please use plain text.
Developer
slashkyle
Posts: 814
Registered: ‎10-16-2012
My Device: Red Z10, Dev Alpha C
My Carrier: Telus

Re: support different languages on blackberry 10

I got this working yesterday it was fairly simple, but one thing that's set me back is i'm using the static asset selector for different screen sizes, but the .ts files aren't updated with my qsTr() from the main.qml located in 2 of my other resolutions it only has the information from my default main.qml

 

is there any way to get it to use different translations for different screen sizes?

Please use plain text.
Contributor
CrystalBullet
Posts: 19
Registered: ‎02-14-2013
My Device: Red Z10
My Carrier: WIND Mobile

Re: support different languages on blackberry 10

In your .pro file you should have something like this:

 

SOURCES += ../src/*.cpp

SOURCES += ../src/somefolder/*.cpp

 

For .qml files to be included, you need:

lupdate_inclusion {

    SOURCES += ../assets/*.qml

}

--
Martin Larochelle
Macadamian
http://bb10ize.me
Please use plain text.
Developer
gdev001
Posts: 163
Registered: ‎01-30-2013
My Device: Blackberry 10 Simulator

Re: support different languages on blackberry 10

Hi, I have added following thing to my .pro file:

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

 found in some app.

 

and in various .cpp files I use QObject::tr("someString") calls, but my .ts files are again empty once I compile... seems I am doing smth wrong still.... :smileysad:((

 

 

 

Please use plain text.
Developer
gdev001
Posts: 163
Registered: ‎01-30-2013
My Device: Blackberry 10 Simulator

Re: support different languages on blackberry 10

>>>Maybe you should try to create your project with the wizard and/or check for differences to the sample projects.

 

hm.. in that case I'd need to copy the files I wrote so far, which is quite some.. I hope I created my project successfully, at least it compiles and runs successfully...

 

although I am getting these problems with all my other projects too: "Description    Resource    Path    Location    Type
Source file of asset "SampleApp1.so" does not exist.    bar-descriptor.xml    /SampleApp1    line 74    BlackBerry App Manifest Problem" -- this I get with all the projects, but still they get compiled and run successfully...

Please use plain text.
Contributor
CrystalBullet
Posts: 19
Registered: ‎02-14-2013
My Device: Red Z10
My Carrier: WIND Mobile

Re: support different languages on blackberry 10

Some things you could look at:

 

  1. Do your objects derive from QObject, and contain Q_OBJECT in the class definition?
  2. Are your source files in sub-folders of /src? Is so you need to specify the folders, $$BASEDIR/../src/*.cpp will not include files in sub folders as: ./src/myComponent/MyClass.cpp

 

--
Martin Larochelle
Macadamian
http://bb10ize.me
Please use plain text.