allpy
changeset 1159:ae4bf19c70ec
compare-aln-3d/web: add language change buttons, save chosen language to cookies
author | Boris Nagaev <bnagaev@gmail.com> |
---|---|
date | Fri, 25 Jan 2013 18:24:20 +0400 |
parents | 2dc0cb47d09a |
children | 460f4eb10155 |
files | pair_cores/web/compare-aln-3d.cpp |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- a/pair_cores/web/compare-aln-3d.cpp Fri Jan 25 18:17:36 2013 +0400 1.2 +++ b/pair_cores/web/compare-aln-3d.cpp Fri Jan 25 18:24:20 2013 +0400 1.3 @@ -47,6 +47,14 @@ 1.4 } 1.5 }; 1.6 1.7 +void update_locale() { 1.8 + try { 1.9 + std::string locale = wApp->environment().getCookie("pc_locale"); 1.10 + wApp->setLocale(locale); 1.11 + } catch (...) 1.12 + { } 1.13 +} 1.14 + 1.15 PairCoresApp::PairCoresApp(const WEnvironment& env): 1.16 WApplication(env) { 1.17 enableUpdates(true); 1.18 @@ -55,6 +63,13 @@ 1.19 messageResourceBundle().use(approot + "locales/pair-cores-web"); 1.20 useStyleSheet("css/pair-cores.css"); 1.21 reset_contents(); 1.22 + update_locale(); 1.23 +} 1.24 + 1.25 +void set_locale(const char* locale) { 1.26 + wApp->setLocale(locale); 1.27 + int five_years = 3600 * 24 * 365 * 5; 1.28 + wApp->setCookie("pc_locale", locale, five_years); 1.29 } 1.30 1.31 void PairCoresApp::reset_contents() { 1.32 @@ -67,6 +82,10 @@ 1.33 } 1.34 WPushButton* reset = new WPushButton(tr("pair.main.Reset"), root()); 1.35 reset->clicked().connect(this, &PairCoresApp::reset_contents); 1.36 + WPushButton* eng = new WPushButton("English", root()); 1.37 + eng->clicked().connect(boost::bind(set_locale, "en")); 1.38 + WPushButton* rus = new WPushButton("Russian", root()); 1.39 + rus->clicked().connect(boost::bind(set_locale, "ru")); 1.40 // 1.41 TableTask* task = new TableTask(root()); 1.42 //