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
Posts: 366
Registered: ‎07-15-2013
My Device: blackberry Z10
My Carrier: Personal

How to translate between languages?

Hello, I think this issue of curiosity, I watched it now bfb your application calls this in different languages, is there any way that the texts that you got in your app, it translates for themselves?.
Could it be that has something to do with the qstr ()?

thanks

If you find this information useful please click like --->
@mezeitune on twitter
Developer
Posts: 16,750
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to translate between languages?

yes, you are on the right track.
see
https://developer.blackberry.com/native/documentation/cascades/device_platform/internationalization/...
----------------------------------------------------------
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
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to translate between languages?

[ Edited ]

This has been answered several times within this forum and just recently in fact here (within a few hours of you posting)...

 

http://supportforums.blackberry.com/t5/Native-Development/Translate-a-button/td-p/2593185

 

A friendly suggestion but are you aware you can search the forums? It's on the top right of the page.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 366
Registered: ‎07-15-2013
My Device: blackberry Z10
My Carrier: Personal

Re: How to translate between languages?

ok thank you very match, i will se this

If you find this information useful please click like --->
@mezeitune on twitter
Highlighted
Contributor
Posts: 48
Registered: ‎08-07-2013
My Device: z10
My Carrier: blackberry

Re: How to translate between languages?

[ Edited ]

Hi,

 

      you can translate the entire app to other language by selecting language with in the app,without changing the device language settings.

 

             if the transudation has to be happened on the device language change,we can by light bit of changes.

 

how to add locale support to app in bb cascades.

1. Open the Pro file of the project.

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

note: subfoldername is the name of the folder in the project explorer where your files are present.

 

2. Open the .qml files and identify the text which we want to translate.

Modify them as: qsTr("text to translate")+Retranslate.onLanguageChanged

 

3. Open the bar-xml file
go to localization tap
then click on the add button
select the language you want to add.
Save it and build it.
We will find .ts and .qm files of our languages

for example : for Arabic it gives projections_ar.ts
noteSmiley Tonguerojections is the name of the our project

if you open the .ts file you will find the text we have to change.
Now to have to paste the transudation words to the obtain words which has to be translated.

 

4.//global declaration.
bb::cascades::Application *application;

Now write a function in the .cpp file


Void App::loadLanguageTranlator(QString localName)
{
//QString filename = QString( "Demo_%1" ).arg( localName );
QString filename = QString(localName);
if (translator->load(filename, "app/native/qm")) {
application->installTranslator( translator );
}
}

call this function in the .qml file on where the language translation has to be happened on selection.make sure that the function is Q_INVOKABLE.

 

example:

 

Container {
topPadding: 20
DropDown {
id: dropDownSelectLanguage
title: qsTr("Select Language") + Retranslate.onLanguageChanged
options: Option {
text: "English"

}
Option {
text: "Arabic"
}

onSelectedOptionChanged: {
languagechange()
}

 

this the example of a dropdown list having different languages on language selection it is calling the function "languagechange()" it is a user defined function.where actual translation function is called.

it is as shown below

 

function languagechange()
{
if(dropDownSelectLanguage.selectedOption.text=="English")
{
app.saveValues("getlan","Demo_es")
app.loadLanguageTranlator(app.getValues("getlan",""));
}
if (dropDownSelectLanguage.selectedOption.text == "Arabic") {
app.saveValues("getlan", "Demo_ar")
app.loadLanguageTranlator(app.getValues("getlan", ""));
}
}

getlan is the variable holds the name.

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to translate between languages?

@tnavabothu I applaud your attempt to help however if you use the 'Insert code' button (the clipboard with a C in) it will be a lot more readable, also a little spell checking wouldn't hurt either. Smiley Happy


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 366
Registered: ‎07-15-2013
My Device: blackberry Z10
My Carrier: Personal

Re: How to translate between languages?

going effort,thank you very much, the truth that you strove to answer me, thank you very much, I'm going to try some, this weekend when I have time week

If you find this information useful please click like --->
@mezeitune on twitter