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
cmr1990
Posts: 59
Registered: ‎10-16-2013
My Device: Z10
My Carrier: vodaphone

Localization problem

Hello all,

 

I'm not able to add localization in my application.

i did go through all the topic already discussed regarding the same with no avail.

This is what i have done :

 

1) in bar.xml file, added english and french languages.

2) in pro file of translations added lines :

 

include (../WingsMobileClient.pro)
lupdate_inclusion {
SOURCES += $$BASEDIR/../src/wingsmessage/OnLocationEvent.cpp \
SOURCES += $$BASEDIR/../src/wmcservices/CallByCorebridgeWebService.cpp \
SOURCES += $$BASEDIR/../src/wmcservices/CallLogWebService.cpp \
SOURCES += $$BASEDIR/../src/wmcservices/ColleagueNearByWebService.cpp \
SOURCES += $$BASEDIR/../src/wmcservices/CoreTeamWebService.cpp \
SOURCES += $$BASEDIR/../src/utilities/contactsmanager/ContactsManager.cpp \
SOURCES += $$BASEDIR/../src/communication/WingsCommunication.cpp \
SOURCES += $$BASEDIR/../src/resources/WmcStrings.cpp \                  //This file contains the string i want to translate
}

TRANSLATIONS = \
$${TARGET}_fr.ts \
$${TARGET}_en.ts \
$${TARGET}.ts

 

3) the ts file (un edited) that was generated is :

 

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="en_US">
<context>
<name>QObject</name>
<message>
<location filename="../src/communication/WingsCommunication.cpp" line="245"/>
<source>Network Available</source>
<comment>WingsCommunication</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/communication/WingsCommunication.cpp" line="259"/>
<source>Preferred Network Not Available</source>
<comment>WingsCommunication</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/communication/WingsCommunication.cpp" line="317"/>
<source>Please check server details.</source>
<comment>WingsCommunication</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/communication/WingsCommunication.cpp" line="328"/>
<source>Connected to External Server</source>
<comment>WingsCommunication</comment>
<translation type="unfinished"></translation>
</message>

.........

 

4)i edited the same with french strings :

 

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="en_US">
<context>
<name>QObject</name>
<message>
<location filename="../src/communication/WingsCommunication.cpp" line="245"/>
<source>Network Available</source>
<comment>WingsCommunication</comment>
<translation>Réseau disponible</translation>
</message>
<message>
<location filename="../src/communication/WingsCommunication.cpp" line="259"/>
<source>Preferred Network Not Available</source>
<comment>WingsCommunication</comment>
<translation>Réseau préféré Indisponible</translation>
</message>
<message>
<location filename="../src/communication/WingsCommunication.cpp" line="317"/>
<source>Please check server details.</source>
<comment>WingsCommunication</comment>
<translation>S'il vous plaît vérifier les détails du serveur.</translation>
</message>
.......................

 

5) in my file src/resources/WmcStrings.cpp i'm using the strings as :

 

const QString WmcStrings::NetworkAvailable = QObject::tr("Network Available") ;
const QString WmcStrings::PreferredNetworkNotAvailable = QObject::tr("Preferred Network Not Available") ;

.....................

 

i run my code and change the language to french and region to france, yet NOTHING!

also in the slot : ApplicationUI::smileysurprised:nSystemLanguageChanged() i print the variable locale_string and it does give me fr_ts, is there anything i'm missing?

 

Please use plain text.
Regular Contributor
cmr1990
Posts: 59
Registered: ‎10-16-2013
My Device: Z10
My Carrier: vodaphone

Re: Localization problem

P.S : i have by mistake written en_US, i have added the strings to fr_ts file, properly.

Please use plain text.
BlackBerry Development Advisor
EunKyung
Posts: 41
Registered: ‎09-27-2012
My Device: Z30
My Carrier: Any

Re: Localization problem

[ Edited ]

Have you resolved the issue yet? If not, I recommend to review our "Hello World" sample app. 

 

https://github.com/blackberry/Cascades-Samples/tree/master/hellocascades

 

Let me know if you have more questions! I can help you wtih. 

----------------------------------------------------
Hope this was helpful. Happy Coding!
I am on twitter @echoTown
Please use plain text.
Developer
pirateshady
Posts: 19
Registered: ‎01-09-2014
My Device: BB Q5
My Carrier: Vodafone

Re: Localization problem

i have added the following two labels in the main.qml of the hellocascades example ---

 

Label {
text: qsTr("Second Label") + Retranslate.onLanguageChanged
verticalAlignment: VerticalAlignment.Bottom
horizontalAlignment: HorizontalAlignment.Left

}
Label {
text: qsTr("This is testing of localization ") + Retranslate.onLanguageChanged
textStyle.fontWeight: FontWeight.Bold
verticalAlignment: VerticalAlignment.Top
horizontalAlignment: HorizontalAlignment.Left

}

 

Now when I change the language of the device to spanish, and then run the app ........ only the "Hello World" is changed to spanish , and the other two texts(labels which I added later) are  not changed  !!

 

Why is it so ?????

Please use plain text.
BlackBerry Development Advisor
EunKyung
Posts: 41
Registered: ‎09-27-2012
My Device: Z30
My Carrier: Any

Re: Localization problem

Have you recreated translation resource files(.ts, .qm)? Also make sure you have updated the translation of the new strings in .ts file.

----------------------------------------------------
Hope this was helpful. Happy Coding!
I am on twitter @echoTown
Please use plain text.