diff options
author | Jose <jose@zeroc.com> | 2012-10-08 22:16:01 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2012-10-08 22:16:01 +0200 |
commit | a622e1cbab7ff128f11e9557967ac0f8e70befbd (patch) | |
tree | d26079e8255d373ebca5006844efee7377049ac1 /cpp/demo/IceGrid/icebox/HelloI.cpp | |
parent | removed first "dummy" parameter for getIn in Ice/custom/AllTests.cpp (diff) | |
download | ice-a622e1cbab7ff128f11e9557967ac0f8e70befbd.tar.bz2 ice-a622e1cbab7ff128f11e9557967ac0f8e70befbd.tar.xz ice-a622e1cbab7ff128f11e9557967ac0f8e70befbd.zip |
Fixed ICE-4561 - IceGrid demo with <env>
Diffstat (limited to 'cpp/demo/IceGrid/icebox/HelloI.cpp')
-rw-r--r-- | cpp/demo/IceGrid/icebox/HelloI.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/cpp/demo/IceGrid/icebox/HelloI.cpp b/cpp/demo/IceGrid/icebox/HelloI.cpp index c2c0a037fa4..40736c95b78 100644 --- a/cpp/demo/IceGrid/icebox/HelloI.cpp +++ b/cpp/demo/IceGrid/icebox/HelloI.cpp @@ -20,5 +20,33 @@ HelloI::HelloI(const string& serviceName) : void HelloI::sayHello(const Ice::Current&) { - cout << "Hello from " << _serviceName << endl; +#ifdef _WIN32 + vector<wchar_t> buf; + buf.resize(1024); + DWORD val = GetEnvironmentVariableW(IceUtil::stringToWstring("LANG").c_str(), &buf[0], + static_cast<DWORD>(buf.size())); + string lang = (val > 0 && val < buf.size()) ? IceUtil::wstringToString(&buf[0]) : string("en"); +#else + char* val = getenv("LANG"); + string lang = val ? string(val) : "en"; +#endif + + string greeting = "Hello, "; + if(lang == "fr") + { + greeting = "Bonjour, "; + } + else if(lang == "de") + { + greeting = "Hallo, "; + } + else if(lang == "es") + { + greeting = "Hola, "; + } + else if(lang == "it") + { + greeting = "Ciao, "; + } + cout << greeting << _serviceName << endl; } |