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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 16
Registered: ‎07-12-2012
My Device: BlackBerry Z10 Limited Edition
My Carrier: Virgin Mobile Canada
Accepted Solution

Dynamic translation with Retranslate

Hi there,

 

I am trying to implement dynamic translation in my app using Retranslate (http://developer.blackberry.com/cascades/reference/bb__cascades__qmlretranslate.html)

 

My translations already work when changing the locale in the device and rebooting the app but I want to be able to change the language directly from my app's settings and that it applies dynamicly to the interface.

 

I do exactly as in the exemple :

 

void MyApp::changeLanguage(const QString &lang){
	QTranslator translator;
	if(translator.load("myapp_" + lang + ".qm", "app/native/qm")){
		Application::instance()->installTranslator(&translator);
		qDebug() << "Translated in " << lang;
	}
	else
		qDebug() << "Failed to translate";
}

 I also added the  "Retranslate.onLanguageChanged" suffix to my labels in qml.

 

From the console I can see that the translator loads correctly as it enters the if. But the text stays in the current language no matter what.

Am I missing a step?

 

Thanks!

Developer
Posts: 16
Registered: ‎07-12-2012
My Device: BlackBerry Z10 Limited Edition
My Carrier: Virgin Mobile Canada

Re: Dynamic translation with Retranslate

Anyone can help me on this?

 

I still haven't found a solution, but will update if I ever find one... Gotta say I moved on other features of my app, putting this one aside for the time being.

Developer
Posts: 196
Registered: ‎03-04-2013
My Device: BB Z10
My Carrier: Rogers

Re: Dynamic translation with Retranslate

Hey there..  Perhaps this thread will help you solve your problem..  The solution was provided by ekke..

 

http://supportforums.blackberry.com/t5/Cascades-Development/Translate-dynamically/td-p/1969625

Developer
Posts: 16
Registered: ‎07-12-2012
My Device: BlackBerry Z10 Limited Edition
My Carrier: Virgin Mobile Canada

Re: Dynamic translation with Retranslate

Thanks for the reply!

 

I had already tumbled upon this thread before posting here. At that time I looked into OpenDataSpace code and tests things for hours...

 

Now I re-read that thread and saw that line :


simon_hain wrote:
[...]i used a local variable for the translator, and after the method completed it went out of scope.

That was exactly my problem!!! I was using a local variable.

Decalring the variable global solved the problem. Thanks a lot!

Developer
Posts: 196
Registered: ‎03-04-2013
My Device: BB Z10
My Carrier: Rogers

Re: Dynamic translation with Retranslate

It's good that you solved your problem, but you should set your post as the solution though Smiley Happy