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 11 #include <ctime> 12 main()13int main() 14 { 15 using namespace boost::locale; 16 using namespace std; 17 18 // Create system default locale 19 generator gen; 20 locale loc=gen(""); 21 locale::global(loc); 22 wcout.imbue(loc); 23 24 // This is needed to prevent C library to 25 // convert strings to narrow 26 // instead of C++ on some platforms 27 std::ios_base::sync_with_stdio(false); 28 29 30 wcout <<wformat(L"Today {1,date} at {1,time} we had run our first localization example") % time(0) 31 <<endl; 32 33 wcout<<L"This is how we show numbers in this locale "<<as::number << 103.34 <<endl; 34 wcout<<L"This is how we show currency in this locale "<<as::currency << 103.34 <<endl; 35 wcout<<L"This is typical date in the locale "<<as::date << std::time(0) <<endl; 36 wcout<<L"This is typical time in the locale "<<as::time << std::time(0) <<endl; 37 wcout<<L"This is upper case "<<to_upper(L"Hello World!")<<endl; 38 wcout<<L"This is lower case "<<to_lower(L"Hello World!")<<endl; 39 wcout<<L"This is title case "<<to_title(L"Hello World!")<<endl; 40 wcout<<L"This is fold case "<<fold_case(L"Hello World!")<<endl; 41 42 } 43 44 45 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 46