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
New Developer
hanyg
Posts: 14
Registered: ‎12-23-2012
My Device: dev alpha simulator
My Carrier: rogers

C++ Files - Localization Question

Hello,

 

I'm using the tr() function to wrap the strings I need to localize. They are not being picked and added to to generated and updated ts files. Are there additional steps required when configuring the project to have the C++ files scanned in addition to the QML files. Everything else is working correctly.

 

Thanks,

Hany

Please use plain text.
Developer
MagnumOpus
Posts: 101
Registered: ‎01-03-2013
My Device: n/a
My Carrier: n/a

Re: C++ Files - Localization Question

How have you created the .ts files?
Regards.

If my answer has been useful to you, please, click the button
Please use plain text.
New Developer
hanyg
Posts: 14
Registered: ‎12-23-2012
My Device: dev alpha simulator
My Carrier: rogers

Re: C++ Files - Localization Question

Hi,

 

Yes, the files are being created but they only contain the localized strings I've identified from the qml files. My strings identified in the c++ sources using tr() are not being merged in.

 

Thanks,

Hany

Please use plain text.
New Developer
hanyg
Posts: 14
Registered: ‎12-23-2012
My Device: dev alpha simulator
My Carrier: rogers

Re: C++ Files - Localization Question

Hi,

 

I just got it to work but I don't think my approach is quite right. I updated the config.pri file as follows (in bold):

 

# Auto-generated by IDE. All changes by user will be lost!

# Created at 1/4/13 6:53 AM

 

BASEDIR = $$_PRO_FILE_PWD_

 

INCLUDEPATH +=  \

    $$BASEDIR/src

 

SOURCES +=  \

    $$BASEDIR/src/LoanShark.cpp \

    $$BASEDIR/src/html_template.cpp \

    $$BASEDIR/src/main.cpp

 

HEADERS +=  \

    $$BASEDIR/src/LoanShark.hpp \

    $$BASEDIR/src/currency.hpp \

    $$BASEDIR/src/html_template.h

 

CONFIG += precompile_header

PRECOMPILED_HEADER = $$BASEDIR/precompiled.h

 

lupdate_inclusion {

    SOURCES = \

    $$BASEDIR/../src/LoanShark.cpp \

    $$BASEDIR/../src/html_template.cpp \

    $$BASEDIR/../src/main.cpp \

        $$BASEDIR/../assets/*.qml

}

 

TRANSLATIONS = \

    $${TARGET}_de.ts \

    $${TARGET}_fr_CA.ts \

    $${TARGET}_fr_FR.ts \

    $${TARGET}.ts

 

 

I manually added the lupdate_inclusions to include my c++ sources so that they are relative to the translations folder from where the lupdate command gets executed. The changes will get lost the next time the IDE generates or updates the config.pri files. So, its an ugly hack at best. I think there is a bug here unless I'm missing something.

 

I'm posting in case someone else runs into this.

 

Thanks,

Hany

 

Please use plain text.
Developer
MagnumOpus
Posts: 101
Registered: ‎01-03-2013
My Device: n/a
My Carrier: n/a

Re: C++ Files - Localization Question

Have you configured the bar-descriptor.xml?

Regards.

If my answer has been useful to you, please, click the button
Please use plain text.
New Developer
hanyg
Posts: 14
Registered: ‎12-23-2012
My Device: dev alpha simulator
My Carrier: rogers

Re: C++ Files - Localization Question

Yes, I did. I set up the languages I reuqired etc. The ts files only contained the qml identified strings. The ones marked by the use of qsTr. My cpp strings, those marked by tr() did not get picked up. Looks like the cpp files were not correctly being picked up. I fixed the issue as per my last post by updating the config.pri file. Its a hack because I will lose the changes once the IDE updates that file, so it is not an ideal solution. I think it is a bug.

 

Hany

Please use plain text.
Developer
MagnumOpus
Posts: 101
Registered: ‎01-03-2013
My Device: n/a
My Carrier: n/a

Re: C++ Files - Localization Question

I made a test and you're right, It doesn't get them.

It should be somethinng like this according to Localization:

 

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="en_GB">
<context>
    <name>main</name>
    <message>
        <location filename="../assets/app.cpp" line="6"/>
        <source>My String</source>
	<comment>My Context</comment>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="../assets/main.qml" line="12"/>
        <source>Hello world</source>
        <translation type="unfinished"></translation>
    </message>
</context>
</TS>

 

In my case location tag isn't there.

 

 

Regards.

If my answer has been useful to you, please, click the button
Please use plain text.
New Developer
hanyg
Posts: 14
Registered: ‎12-23-2012
My Device: dev alpha simulator
My Carrier: rogers

Re: C++ Files - Localization Question

 

 

Thanks for confirming. Is there a mechanism to report bugs we find that you are aware of?

 

Hany

Please use plain text.
Developer
Zmey
Posts: 1,509
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: C++ Files - Localization Question

There's Issue Tracker:

https://www.blackberry.com/jira/browse/BBTEN


Andrey Fidrya, @zmeyc on twitter
Please use plain text.