+#ifdef _WIN32
+/**
+ * Determine locale/language settings on Windows.
+ *
+ * Copyright (C) 1997, 2002, 2003 Martin von Loewis
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies.
+ *
+ * This software comes with no warranty. Use at your own risk.
+ */
+string_list
+FGLocale::getUserLanguage()
+{
+ string_list result;
+ static char locale[100] = {0};
+
+ if (GetLocaleInfo(LOCALE_USER_DEFAULT,
+ LOCALE_SISO639LANGNAME,
+ locale, sizeof(locale)))
+ {
+ SG_LOG(SG_GENERAL, SG_DEBUG, "Detected locale's language setting: " << locale);
+ size_t i = strlen(locale);
+ locale[i++] = '_';
+ if (GetLocaleInfo(LOCALE_USER_DEFAULT,
+ LOCALE_SISO3166CTRYNAME,
+ locale+i, (int)(sizeof(locale)-i)))
+ {
+ result.push_back(locale);
+ return result;
+ }
+
+ locale[--i] = 0;
+ SG_LOG(SG_GENERAL, SG_WARN, "Failed to detected locale's country setting.");
+ result.push_back(locale);
+ return result;
+ }
+
+ return result;
+}
+#elif __APPLE__
+// implemented in CocoaHelpers.mm
+#else
+/**
+ * Determine locale/language settings on Linux/Unix.
+ */
+string_list
+FGLocale::getUserLanguage()
+{
+ string_list result;
+ const char* langEnv = ::getenv("LANG");
+ if (langEnv) {
+ result.push_back(langEnv);
+ }
+
+ return result;
+}
+#endif
+