One more Mac helper moved into CocoaHelpers.mm
This commit is contained in:
parent
875227057c
commit
1f699984e9
3 changed files with 16 additions and 23 deletions
|
@ -33,6 +33,7 @@
|
|||
// flightgear
|
||||
#include <GUI/MessageBox.hxx>
|
||||
#include <Main/options.hxx>
|
||||
#include <Main/locale.hxx>
|
||||
|
||||
NSString* stdStringToCocoa(const std::string& s)
|
||||
{
|
||||
|
@ -138,3 +139,15 @@ std::string Options::platformDefaultRoot() const
|
|||
}
|
||||
|
||||
} // of namespace flightgear
|
||||
|
||||
string_list FGLocale::getUserLanguage()
|
||||
{
|
||||
CocoaAutoreleasePool ap;
|
||||
string_list result;
|
||||
|
||||
for (NSString* lang in [NSLocale preferredLanguages]) {
|
||||
result.push_back(stdStringFromCocoa(lang));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -90,27 +90,7 @@ FGLocale::getUserLanguage()
|
|||
return result;
|
||||
}
|
||||
#elif __APPLE__
|
||||
|
||||
// determine locale / langauge on Mac
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
string_list
|
||||
FGLocale::getUserLanguage()
|
||||
{
|
||||
string_list result;
|
||||
CFArrayRef langs = CFLocaleCopyPreferredLanguages();
|
||||
|
||||
char buffer[64];
|
||||
for (int i=0; i<CFArrayGetCount(langs); ++i) {
|
||||
CFStringRef s = (CFStringRef) CFArrayGetValueAtIndex(langs, i);
|
||||
CFStringGetCString(s, buffer, 64, kCFStringEncodingASCII);
|
||||
result.push_back(buffer);
|
||||
}
|
||||
|
||||
CFRelease(langs);
|
||||
return result;
|
||||
}
|
||||
|
||||
// implemented in CocoaHelpers.mm
|
||||
#else
|
||||
/**
|
||||
* Determine locale/language settings on Linux/Unix.
|
||||
|
|
|
@ -2346,12 +2346,12 @@ string Options::platformDefaultRoot() const
|
|||
return "../data";
|
||||
}
|
||||
|
||||
#elif defined(_WIN32)
|
||||
#elif defined(SG_WINDOWS)
|
||||
string Options::platformDefaultRoot() const
|
||||
{
|
||||
return "..\\data";
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(SG_MAC)
|
||||
// platformDefaultRoot defined in CocoaHelpers.mm
|
||||
#else
|
||||
string Options::platformDefaultRoot() const
|
||||
|
|
Loading…
Reference in a new issue