hello.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See
  5. // accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. #include <boost/locale.hpp>
  9. #include <iostream>
  10. #include <ctime>
  11. int main()
  12. {
  13. using namespace boost::locale;
  14. using namespace std;
  15. generator gen;
  16. locale loc=gen("");
  17. // Create system default locale
  18. locale::global(loc);
  19. // Make it system global
  20. cout.imbue(loc);
  21. // Set as default locale for output
  22. cout <<format("Today {1,date} at {1,time} we had run our first localization example") % time(0)
  23. <<endl;
  24. cout<<"This is how we show numbers in this locale "<<as::number << 103.34 <<endl;
  25. cout<<"This is how we show currency in this locale "<<as::currency << 103.34 <<endl;
  26. cout<<"This is typical date in the locale "<<as::date << std::time(0) <<endl;
  27. cout<<"This is typical time in the locale "<<as::time << std::time(0) <<endl;
  28. cout<<"This is upper case "<<to_upper("Hello World!")<<endl;
  29. cout<<"This is lower case "<<to_lower("Hello World!")<<endl;
  30. cout<<"This is title case "<<to_title("Hello World!")<<endl;
  31. cout<<"This is fold case "<<fold_case("Hello World!")<<endl;
  32. }
  33. // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4