mac: update of macosx_bundle.sh (#5786)
Various changes to improve compilation of RT on macOS thanks to @Benitoite and @Pandagrapher * mac: use sed -i.bak, add X's to mktemp template in macosx_bundle.sh * mac: test lensfun version in macosx_bundle.sh to select correct lensfun database version (version_1 for 3.2 and version_2 for 3.95) * mac: remove DYLD_FALLBACK_LIBRARY_PATH from main Info.plist * mac: removes some -cli codesigning commands * mac: remove erroneous newlines in macosx_bundle.sh and suppress superfluous codesigning of Contents/Frameworks/*dylib * mac: Apple arm64/homebrew compatibility update * mac: CMakeLists.txt arm64 homebrew compatibility * mac: add Apple arm64 CPU native flag * mac: fix pixbuf query syntax * mac: adapt. of Pandagrapher's patch * mac: additional instructions for the -cli exec. * mac: revert target 10 * mac: remove legacy environment variable Per https://github.com/Beep6581/RawTherapee/pull/5786#issuecomment-792276656 * mac: fix destination of credits/license * mac: copy {LOCAL_PREFIX}/share/locale to bundle * mac: fixes a path for the License * mac: fix of UpdateInfo command structure * mac: remove redundant copying * mac: use cmake to configure Info.plist values * mac: configurator for Info.plist version values * mac: fix locale detection / language * mac: remove an outdated key from Info.plist * mac: fix path usage for gtk.immodules / locale dir * mac: revert a change merged elsewhere * mac: follow more symlinks for 'brew builds * mac: link to CoreFoundation for locale detection * mac: link CoreFoundation for locale / C * mac: detect locale with CoreFoundation per https://github.com/Beep6581/RawTherapee/pull/5786#issuecomment-798926898 * mac: remove outdated lines * Update multilangmgr.cc * mac: Info.plist language fixes (Pandagrapher) https://github.com/Beep6581/RawTherapee/pull/5786#issuecomment-813004475 * Mac: also package libpng12 for homebrew compatibility. * macOS packaging and language updates
This commit is contained in:
@@ -24,6 +24,9 @@
|
||||
#include <windows.h>
|
||||
#include <winnls.h>
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -122,6 +125,20 @@ void setGtkLanguage(const Glib::ustring &language)
|
||||
{
|
||||
if(language != "default") { // nothing to change when using default
|
||||
std::string lang = localeToLang.getLocale(language);
|
||||
#ifdef __APPLE__
|
||||
|
||||
// On MacOS, LANG environment variable is not defined when running app bundle
|
||||
// So we should set all locale data
|
||||
const Glib::ustring localeUTF8 = lang + ".UTF-8";
|
||||
|
||||
lang = lang + ".UTF-8"; // According to Apple documentation, UTF-8 is a built-in encoding on all platforms on which macOS runs
|
||||
|
||||
g_setenv("LANG", lang.c_str(), true);
|
||||
setlocale(LC_ALL, lang.c_str());
|
||||
setlocale (LC_NUMERIC, "C"); // Force decimal point to dot.
|
||||
|
||||
#else
|
||||
|
||||
const gchar *env_langc = g_getenv("LANG");
|
||||
if(env_langc) {
|
||||
const std::string env_lang(env_langc);
|
||||
@@ -134,6 +151,8 @@ void setGtkLanguage(const Glib::ustring &language)
|
||||
}
|
||||
|
||||
g_setenv("LANG", lang.c_str(), true);
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +247,7 @@ Glib::ustring MultiLangMgr::getOSUserLanguage ()
|
||||
|
||||
langName = localeToLang (localeName);
|
||||
|
||||
#elif defined (__linux__) || defined (__APPLE__)
|
||||
#elif defined (__linux__)
|
||||
|
||||
// Query the current locale and force decimal point to dot.
|
||||
const char *locale = getenv("LANG");
|
||||
@@ -238,6 +257,51 @@ Glib::ustring MultiLangMgr::getOSUserLanguage ()
|
||||
|
||||
setlocale (LC_NUMERIC, "C");
|
||||
|
||||
#elif defined (__APPLE__)
|
||||
|
||||
// "LANG" environment variable is not defined. Retrieving it from CoreFundation API
|
||||
// Get used Mac string encoding
|
||||
CFStringEncoding strEncoding = CFStringGetSystemEncoding();
|
||||
// Get user locale data
|
||||
CFLocaleRef cfLocale = CFLocaleCopyCurrent();
|
||||
// Get locale language code
|
||||
CFStringRef langCodeStr = (CFStringRef)CFLocaleGetValue(cfLocale, kCFLocaleLanguageCode);
|
||||
Glib::ustring langCode("");
|
||||
|
||||
if (langCodeStr != NULL) {
|
||||
const auto langCodeStrLength = CFStringGetLength(langCodeStr) + 1;
|
||||
char langCodeBuffer[langCodeStrLength];
|
||||
CFStringGetCString(langCodeStr, langCodeBuffer, langCodeStrLength, strEncoding);
|
||||
langCode = Glib::ustring(langCodeBuffer);
|
||||
}
|
||||
|
||||
// Get locale country code
|
||||
CFStringRef countryCodeStr = (CFStringRef)CFLocaleGetValue(cfLocale, kCFLocaleCountryCode);
|
||||
Glib::ustring countryCode("");
|
||||
|
||||
if (countryCodeStr != NULL) {
|
||||
const auto countryCodeStrLength = CFStringGetLength(countryCodeStr) + 1;
|
||||
char countryCodeBuffer[countryCodeStrLength];
|
||||
CFStringGetCString(countryCodeStr, countryCodeBuffer, countryCodeStrLength, strEncoding);
|
||||
countryCode = Glib::ustring(countryCodeBuffer);
|
||||
}
|
||||
|
||||
// Concatenate locale data
|
||||
Glib::ustring locale = langCode + "_" + countryCode;
|
||||
|
||||
// Release user locale data
|
||||
CFRelease(cfLocale);
|
||||
CFRelease(langCodeStr);
|
||||
CFRelease(countryCodeStr);
|
||||
|
||||
// Set locale environment data
|
||||
locale = locale + ".UTF-8"; // According to Apple documentation, UTF-8 is a built-in encoding on all platforms on which macOS runs
|
||||
g_setenv("LANG", locale.c_str(), true);
|
||||
setlocale(LC_ALL, locale.c_str());
|
||||
setlocale (LC_NUMERIC, "C"); // Force decimal point to dot.
|
||||
|
||||
langName = localeToLang(locale);
|
||||
|
||||
#endif
|
||||
|
||||
return langName;
|
||||
|
Reference in New Issue
Block a user