// Bug 661588 - Set the global locale in Glib::init()

#include <locale>
#include <clocale>
#include <iostream>

#include <glibmm.h>
#include <gtkmm.h>

int main(int argc, char *argv[])
{
  std::cout << "Before Glib::init()\n";
  const char* c_locale = std::setlocale(LC_ALL, nullptr);
  if (c_locale)
    std::cout << "std::setlocale(LC_ALL, nullptr)=" << c_locale << std::endl;
  std::cout << "std::locale().name()=" << std::locale().name() << std::endl;

  Glib::init();
  std::cout << "\nAfter Glib::init()\n";
  c_locale = std::setlocale(LC_ALL, nullptr);
  if (c_locale)
    std::cout << "std::setlocale(LC_ALL, nullptr)=" << c_locale << std::endl;
  std::cout << "std::locale().name()=" << std::locale().name() << std::endl;

  auto app = Gtk::Application::create(argc, argv, "org.gtkmm.testinit");
  std::cout << "\nAfter Gtk::Application::create()\n";
  c_locale = std::setlocale(LC_ALL, nullptr);
  if (c_locale)
    std::cout << "std::setlocale(LC_ALL, nullptr)=" << c_locale << std::endl;
  std::cout << "std::locale().name()=" << std::locale().name() << std::endl;

  return 0;
}
