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
Regular Contributor
Posts: 68
Registered: ‎03-13-2012
My Device: Playbook
My Carrier: Rodgers

qsTr not working ?

[ Edited ]

Hi, I am obtaining a query and inserting a query into a model.

 

I have checked the data being inserted into the model it turns out to be fine.

 

//My list item component looks like this

 listItemComponents:

        [

            ListItemComponent 

            {

                id: lComponent

                type: "item"

                Container 

                {

                    layout: StackLayout {}

                Label

                {                 

                    id: id

                    layoutProperties: StackLayoutProperties {}

                    text:qsTr("Unique Key: %1").arg(ListItemData.getID)

                   

                }

                Label

                {

                    id: date

                        layoutProperties: StackLayoutProperties {}

                        text:qsTr("date: %1").arg(ListItemData.getDate)

                }

                Label

                {

                    id: time

                        layoutProperties: StackLayoutProperties {}

                        text:qsTr("time: %1").arg(ListItemData.getTime)

                    }

                Label

                {

                    id: name

                        layoutProperties: StackLayoutProperties {}

                        text: qsTr("name: %1").arg(ListItemData.getName)

                    }

                Label

                {

                id: description

                        layoutProperties: StackLayoutProperties {}

                        text:qsTr("description: %1").arg(ListItemData.getDescription)

                    }

               

                }

            }

        ]// ListItemComponents End

 

// It does not appear to return the properties to the list?

I have tried the list with default values like "hello" it works just fine.

 

in the device log I get

 

default 9000 INFO Read: 6 Record(s)
default 0 INFO MKS6222991DEBUG:Smiley TongueroduceItemForIndexPath 1, releasing : 84f247c
default 0 INFO MKS6222991DEBUG:Smiley TongueroduceItemForIndexPath 1, releasing : 84f247c
default 0 INFO MKS6222991DEBUG:Smiley TongueroduceItemForIndexPath 1, releasing : 84f247c
default 0 INFO MKS6222991DEBUG:Smiley TongueroduceItemForIndexPath 1, releasing : 84f247c
default 0 INFO MKS6222991DEBUG:Smiley TongueroduceItemForIndexPath 1, releasing : 84f247c
default 0 INFO MKS6222991DEBUG:Smiley TongueroduceItemForIndexPath 1, releasing : 84f247c

 

which is odd I know what MKS is but this shouldn't be produced in the release bb10 cascades

 

on my list I have no strings showing up its a blank list Smiley Frustrated can anyone help me out ? 

 

// This data is outlined in the model like so if anyone is wondering.

 

Q_PROPERTY(QString id READ getID WRITE setID); // for every property variable in the model class.

 

Developer
Posts: 222
Registered: ‎11-05-2011
My Device: Z10
My Carrier: Beeline

Re: qsTr not working ?

[ Edited ]
good, you translate into _[locale].ts files?
Regular Contributor
Posts: 68
Registered: ‎03-13-2012
My Device: Playbook
My Carrier: Rodgers

Re: qsTr not working ?

I am not quite sure what your refering to ? hmm can you show me a reference to why I must do what you say as well how to do it ? 

Developer
Posts: 222
Registered: ‎11-05-2011
My Device: Z10
My Carrier: Beeline

Re: qsTr not working ?

1) add locale in bar-description (add icon, appp name and description in new locale)

2) run your app at emulator or phone (for generating fresh .ts files

3) go to translation folder of your project

4) find .ts files for italian is [yourprojectname]_it.ts for russian is [yourprojectname]_ru.ts

5) open that files and add translation to unfinished tags for words

6) run app and get translation (if you change locale at phone)

 

Regular Contributor
Posts: 68
Registered: ‎03-13-2012
My Device: Playbook
My Carrier: Rodgers

Re: qsTr not working ?

So the reason for this not working is due to the fact that I have not setup localization correctly ? 

Regular Contributor
Posts: 68
Registered: ‎03-13-2012
My Device: Playbook
My Carrier: Rodgers

Re: qsTr not working ?

//This generated an error that qsTr() first argument must be a string.
Whats odd is it is a QString supposed to be returned.
Label
{
id: id
layoutProperties: StackLayoutProperties {}
text: qsTr(ListItemData.getID)

}
// This returns no error but that wierd MKSDEBUG deal.
Label
{
id: date
layoutProperties: StackLayoutProperties {}
text: ListItemData.getDate
}

why does this have to do with translations I am using the default language. and I have looked at the files and they contain this

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="en_CA">
<context>
<name>TimeFragmentOperationsAddPage</name>
<message>
<location filename="../assets/qml/TimeFragmentOperationsAddPage.qml" line="24"/>
<source>Event Name</source>
<translation type="unfinished">Event Name</translation>
</message>
<message>
<location filename="../assets/qml/TimeFragmentOperationsAddPage.qml" line="33"/>
<source>Event Description</source>
<translation type="unfinished">Event Name<</translation>
</message>
<message>
<location filename="../assets/qml/TimeFragmentOperationsAddPage.qml" line="41"/>
<source>Create Time Fragment</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

 

which have nothing to do with the ListItemData.whateverfunctiontoreaddata

Regular Contributor
Posts: 68
Registered: ‎03-13-2012
My Device: Playbook
My Carrier: Rodgers

Re: qsTr not working ?

I have also checked the group model object and had it return a list of items that Inserted and it did that and it works.

I am wondering what it could be.........

Regular Contributor
Posts: 68
Registered: ‎03-13-2012
My Device: Playbook
My Carrier: Rodgers

Re: qsTr not working ?

Okay

I did what you said above.

 

and I installed the translator

 

mApp=new bb::cascades::Application(argc,argv);

 

// localization support

mLocale_string=QLocale().name();

mFilename=QString(QDir::currentPath()+"/app/native/qm/coolapp.qm");

 

if(mTranslator.load(mFilename))

{

mApp->installTranslator(&mTranslator);

}

 

it still shows up blank ? on my list.

 

Is there a way to check if my listDataModel.getID is returning the right values?