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
Accepted Solution

Localization Question

Hello,

 

I was adding localization changes to my app but not having much success. My understanding is that I would update the .ts file for the locale I want which is what I did. However, subsequent builds overwrite my changes form within the IDE. I couldn't find any examples of the process.

 

Has anyone had any luck building the localization files required from within Eclipse?

Thanks,

Hany

Please use plain text.
Developer
ekke
Posts: 1,460
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Localization Question

1. in bar-descriptor.xml add your languages

2. your .pro file must also contain the languages like

TRANSLATIONS = \
    $${TARGET}_fr.ts \
    $${TARGET}_it.ts \    
    $${TARGET}_de.ts \
    $${TARGET}_en.ts \
    $${TARGET}_es.ts \
    $${TARGET}_ru.ts \
    $${TARGET}.ts

3. in your main.cpp the filename must match

QString filename = QString("OpenDataSpace_%1").arg(locale_string);
	if (translator.load(filename, "app/native/qm")) {
		qDebug() << "install a translator";
		Application::instance()->installTranslator(&translator);
	} else {
		qDebug() << "CANNOT install a translator";
	}

 in this case translator files will be

OpenDataSpace_de.ts ... in folder translations

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
New Developer
hanyg
Posts: 14
Registered: ‎12-23-2012
My Device: dev alpha simulator
My Carrier: rogers

Re: Localization Question

Hi,

 

 

Thanks for the reply.

 

The issue I'm having is that the .ts files are being overwritten when I perform a project build. According to the documentation from https://developer.blackberry.com/cascades/documentation/device_platform/internationalization/localiz...

 

There is a paragraph stating:

 

Subsequent builds automatically update the .ts files with additional strings, however the current translations are not lost. The build process also calls the lrelease function on each build. This process converts the .ts files into binary .qm files. These .qm files are copied as assets to the device and are used as the source for the tr() and qsTr() functions.

 

 
 
In my case, I have English & French(Canada) translation files. My French file LoanShark_fr-CA.ts is being overwritten after each build and my changes are lost.
 
I've updated the .pro file based on your example, but I do not believe it addresses this issue. 

One final note, the build is done from within the IDE.
 
Thanks again,
Hany
Please use plain text.
Developer
ekke
Posts: 1,460
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Localization Question

perhaps your translations are wrong

then all would be re-generated

How are you doing the translations ? manually or with tooling

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
New Developer
hanyg
Posts: 14
Registered: ‎12-23-2012
My Device: dev alpha simulator
My Carrier: rogers

Re: Localization Question

Hi,

 

I'm manually editing the generated .ts file. I wasn't aware of any tooling to assist with the edits. Would that be the cause of the issue?

 

Thanks,

Hany

Please use plain text.
Developer
ekke
Posts: 1,460
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Localization Question

please post a sample how you did your translation inside the .ts file

perhaps you're doinmg something wrong and then will be overwritten

 

for small files you can change inside the .ts file manually

 

for more complex apps its much easier with  QtLinguist app

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
New Developer
hanyg
Posts: 14
Registered: ‎12-23-2012
My Device: dev alpha simulator
My Carrier: rogers

Re: Localization Question

Hi,

 

Here is the file before editing:

 

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE TS>

<TS version="2.0" language="fr_CA">

<context>

    <name>main</name>

    <message>

        <location filename="../assets/main.qml" line="11"/>

        <location filename="../assets/main.qml" line="163"/>

        <source>Personal Loan</source>

        <translation type="unfinished"></translation>

    </message>

    <message>

        <location filename="../assets/main.qml" line="353"/>

        <location filename="../assets/main.qml" line="368"/>

        <source>Mortgage</source>

        <translation type="unfinished"></translation>

    </message>

    <message>

        <location filename="../assets/main.qml" line="602"/>

        <location filename="../assets/main.qml" line="617"/>

        <source>Auto Loan</source>

        <translation type="unfinished"></translation>

    </message>

</context>

</TS>

 

I simply changed the text Auto Loan to test.

 

    <message>

        <location filename="../assets/main.qml" line="602"/>

        <location filename="../assets/main.qml" line="617"/>

        <source>test</source>

        <translation type="unfinished"></translation>

    </message>

 

When I rebuild the edit is lost.

 

 

Any ideas as to why my changes are being overwritten?

 

 

I didn't know about QLinguist. That will be especially helpful when I do the bulk of the translations.

 

 

 

Thanks,

Hany

 

 

 

Please use plain text.
Developer
ekke
Posts: 1,460
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Localization Question

thats your problem,


hanyg wrote:

Hi,

 

Here is the file before editing:

 


 

I simply changed the text Auto Loan to test.

 

    <message>

        <location filename="../assets/main.qml" line="602"/>

        <location filename="../assets/main.qml" line="617"/>

        <source>test</source>

        <translation type="unfinished"></translation>

    </message>

 

When I rebuild the edit is lost.

 

 

 

 


<message>
        <location filename="../assets/main.qml" line="602"/>
        <location filename="../assets/main.qml" line="617"/>
        <source>Auto Loan</source>
        <translation>test</translation>
</message>

you must change the TRANSLATION - the SOURCE will always be overwritten



 

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
New Developer
hanyg
Posts: 14
Registered: ‎12-23-2012
My Device: dev alpha simulator
My Carrier: rogers

Re: Localization Question

 

 

 

D'Ohhh!!!!

 

 

Thanks! Seems so obvious now.

 

Hany

Please use plain text.
Developer
ekke
Posts: 1,460
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Localization Question

BTW: you can also watch my session about Internationalization from BBJAm Americas

http://hosting.desire2learncapture.com/RIM/1/watch/53.aspx

 

or download the PDF:

http://hosting.desire2learncapture.com/RIM/Content/attachments/Archive/53/JAM53.pdf

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.