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
babakar
Posts: 770
Registered: ‎05-29-2012
My Device: see later
Accepted Solution

4 language application

How can I do localization? have 4 languages in my application?

https://developer.blackberry.com/native/documentation/cascades/device_platform/internationalization/...

 

 

I will use QSTR in my qml file okey.

 

 

I also done this on c++ side when application begins

 

 QCoreApplication::instance()->removeTranslator(m_pTranslator);
    // Initiate, load and install the application translation files.
    QString locale_string = QLocale().name();
    QString file_name = QString("Alkhaliji").arg(locale_string);
    if (m_pTranslator->load(file_name, "app/native/qm")) {
        QCoreApplication::instance()->installTranslator(m_pTranslator);
    }

 

 

 

Developer
babakar
Posts: 770
Registered: ‎05-29-2012
My Device: see later

Re: 4 language application

what i did

 

void ApplicationUI::onSystemLanguageChanged()
{
    QCoreApplication::instance()->removeTranslator(m_pTranslator);
    // Initiate, load and install the application translation files.
    QString locale_string = QLocale().name();
    QString file_name = QString("AlKhaliji_%1").arg(locale_string);
    if (m_pTranslator->load(file_name, "app/native/qm")) {
        QCoreApplication::instance()->installTranslator(m_pTranslator);
    }
}

 

 

alkhailiji.ts

 

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0">
<context>
    <name>main</name>
    <message>
        <source>Select your country from the list below</source>
        <translation type="obsolete">Select</translation>
    </message>
</context>
<context>
    <name>service</name>
    <message>
        <location filename="../assets/service.qml" line="35"/>
        <source>Select your country from the list below</source>
        <translation type="unfinished">Select</translation>
    </message>
</context>
</TS>

 

service.qml

 

 text: qsTr("Select your country from the list below")+Retranslate.onLocaleOrLanguageChanged

 

 

how can i specify different translation? and how to specify which one to show?

Developer
babakar
Posts: 770
Registered: ‎05-29-2012
My Device: see later

Re: 4 language application

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0">
<context>
    <name>service</name>
    <message>
        <location filename="../assets/service.qml" line="35"/>
        <source>Select your country from the list below</source>
        <translation>Select23</translation>
    </message>
</context>
</TS>

 

how can i add two translations? and how to specify which one?



Developer
Benecore
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: 4 language application

[ Edited ]

You can add new language in your bar-descriptor.xml
QNX Momentics -> Click bar-descriptor.xml -> Select Localization tab -> Add new language



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
babakar
Posts: 770
Registered: ‎05-29-2012
My Device: see later

Re: 4 language application

okey i have default language and french

how do i specify translation in my .ts files?
Developer
Benecore
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: 4 language application

So you have two *.ts and *.qm files inside folder translations. Just open *.ts file in Qt Linquist and translate it. That's it



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
babakar
Posts: 770
Registered: ‎05-29-2012
My Device: see later

Re: 4 language application

ah ok, thank you.


so when user downloads my app from en.blackberry he will get defalkt language which is english
when he downloads from fr.blackberry he gets french language right?

can i specify in my app..which translation he has to follow? a page for choose language?
Developer
Benecore
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: 4 language application

You're welcome and NO. User will have app language according the system language. If user download app from en.blackberry and than change system language to French then your app will use French langauge



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
babakar
Posts: 770
Registered: ‎05-29-2012
My Device: see later

Re: 4 language application

okey u mena system language from his balckberyr app?
in languages an dinput right?

ok thanks alot
Developer
Benecore
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: 4 language application

[ Edited ]

I mean 'system language' as BlackBerry 10 phone language. And all apps loading languages according this one.

 

You're welcome :smileywink:



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog