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
joelajean
Posts: 132
Registered: ‎01-25-2010
My Device: Z30, Z10, Q10, Dev Alpha B & Bold 9900

Language DropDown control

Hi,

 

Looking for way to populate a dropdown with all the language locales. Dropdown would be similar to the one found on the Language and Input setting screen.

 

Any pointers is appreciated :smileyhappy:

IMG_20140304_220137.png

Author of Shopping Cart Calculator, BP Monitor & Book-zy
@kodybb on Twitter

Developer
laurentC
Posts: 268
Registered: ‎02-05-2010
My Device: Blackberry Z10

Re: Language DropDown control

If you add translations to your project, you don't have to worry about the language selection. The app is translated based on the user language configuration. No need to make him to select the language in your app. It's my opinion of course.
Twitter : @LaurentKP
My apps
Developer
joelajean
Posts: 132
Registered: ‎01-25-2010
My Device: Z30, Z10, Q10, Dev Alpha B & Bold 9900

Re: Language DropDown control

[ Edited ]

Don't need it for translation :smileyhappy: I need the ability for the user to select the language representation related to a data entry which will reside in the local DB. So each entry can be for a different languages, thus why the language selection dropdown comes in handy.

Since BB must have the core languages table stored in the OS, it would be nice if I can fetch these language directly from the OS. Want to avoid maintaning my own langage DB.

 

Thanks

Author of Shopping Cart Calculator, BP Monitor & Book-zy
@kodybb on Twitter

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

Re: Language DropDown control

I've been searching on and off for an answer to this since you posted and the best I've found so far is to scan the locale folder or use the defines, I haven't been able to find any OS api for this.

 


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
joelajean
Posts: 132
Registered: ‎01-25-2010
My Device: Z30, Z10, Q10, Dev Alpha B & Bold 9900

Re: Language DropDown control

Thanks BBSJdev... interesting ! Scan the locale folder and use the defines, any pointers how to accomplish this piece ?

Author of Shopping Cart Calculator, BP Monitor & Book-zy
@kodybb on Twitter

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

Re: Language DropDown control

After doing a little more searching mainly in the header files it looks like QLocale.h contains a comprehensive list and some functions to access string literals as well...

 

https://qt-project.org/doc/qt-4.7/qlocale.html

 

http://developer.blackberry.com/native/reference/cascades/qlocale.html#uiLanguages

 

Do you intend to offer the list in the current locale language?

Seems like a lot of work to me, hope it's worth it. :smileyhappy:


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
joelajean
Posts: 132
Registered: ‎01-25-2010
My Device: Z30, Z10, Q10, Dev Alpha B & Bold 9900

Re: Language DropDown control

My app is only offered in english @ this point. Maybe in the future but for now, I would go with one language.

I'm a C# developper from background. For enums, via C# I usually loop through the set of enum values and use reflection to extract the value and text representation. Is there a similar fonctionality with C++ ? (Still learning C++)

 

Ideally, the dropdown would be constructed using Country Name has the Option text and it's value would contain the Language Code (ie: en_us, en_ca)

I just look @ the reference class quickly, but I haven't seen any method / property that spits out the Language Code, will need to further investigation later this week.

Thanks for the pointer... you rock BBSJev :smileyhappy:

Author of Shopping Cart Calculator, BP Monitor & Book-zy
@kodybb on Twitter

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

Re: Language DropDown control

Ah, that age old question on iterating enums, not a simple answer I'm afraid especially if you are not in control of the enum and the numbers aren't sequential.
Google 'Iterate C++ enums' if you really want to know but it's probably easier just to say enums aren't really meant to be iterated over.

Thanks for the compliment, however although I got *a* solution in this case I'm not sure there isn't some better answer out there somewhere.

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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
joelajean
Posts: 132
Registered: ‎01-25-2010
My Device: Z30, Z10, Q10, Dev Alpha B & Bold 9900

Re: Language DropDown control

NP, might not have a complete solution, but at least the concept is a start. I will be digging into this later, I'll put that data field on hold for now, it's not a show stopper. If I can come up with some sort of solution, might be a good control to push on GitHub.  :smileyhappy:

Author of Shopping Cart Calculator, BP Monitor & Book-zy
@kodybb on Twitter