Localized system dialogs on OS X

Share your advanced PureBasic knowledge/code with the community.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Localized system dialogs on OS X

Post by wilbert »

When compiling with PureBasic for OS X, all system dialogs are english by default.
You can specify in the Info.plist file what languages your application supports.
For each language you add here, the system dialogs will automatically be localized.
Some PureBasic dialogs like MessageRequester seem to be hardcoded in english but OpenFileRequester for example will be localized.

Code: Select all

  <key>CFBundleLocalizations</key>
    <array>
    <string>de</string>
    <string>en</string>
    <string>fr</string>
    <string>nl</string>
    </array>
User avatar
grabiller
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Jun 01, 2011 9:38 am
Location: France - 89220 Rogny-Les-Septs-Ecluses
Contact:

Re: Localized system dialogs on OS X

Post by grabiller »

Thanks for the tip wilbert.

For my localization system, I use this to detect wich language is used on Mac OSX (also on Linux):

Code: Select all

#LC_ALL = 0
Protected lan$ = PeekS( setlocale_( #LC_ALL, "" ) )
If lan$ = "C"
  ProcedureReturn "en"
Else
  ProcedureReturn Left(lan$,2)
EndIf
This will return 'en', 'de', 'fr', 'nl', etc..

Just to be sure, does this sounds like to be the correct way to you for Mac OSX ?
guy rabiller | radfac founder / ceo | raafal.org
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Localized system dialogs on OS X

Post by wilbert »

I'm not sure what your function should return.
If it should return the language of the OS, it doesn't seem to work properly.
On my computer lan$ = "C" and you return that as "en". The system language however is dutch (nl).
For cocoa, I mentioned it here http://www.purebasic.fr/english/viewtop ... 02#p390802 .
User avatar
grabiller
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Jun 01, 2011 9:38 am
Location: France - 89220 Rogny-Les-Septs-Ecluses
Contact:

Re: Localized system dialogs on OS X

Post by grabiller »

Thanks wilbert.

That's interesting to know.

On Linux (and normally in standard C) 'setlocale(LC_ALL,"")' sets and returns the current system locale and in my case it properly returns "fr_FR.UTF" from Ubuntu.

I guess it shouldn't always return 'C' on Mac OSX, but anyway, I'll use your method from your ' [PB Cocoa] Methods, Tips & Tricks' thread instead.

Thanks again.
guy rabiller | radfac founder / ceo | raafal.org
Post Reply