Home » U++ Library support » U++ Libraries and TheIDE: i18n, Unicode and Internationalization » How to change language "on the fly"?
How to change language "on the fly"? [message #26924] |
Wed, 09 June 2010 17:10  |
Zbych
Messages: 327 Registered: July 2009
|
Senior Member |
|
|
Hi,
Is there a way to change language in u++ window without closing and reopening it? Maybe some function that tells all widgets to refresh/redraw texts with new language?
main.cpp:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define TFILE <grid/grid.t>
#include <Core/t.h>
struct ButtonApp : TopWindow {
int count;
Button button;
Label label;
void RefreshLabel()
{
label = Format(t_("Number of button clicks %d, language %s"), count, GetLangName(GetCurrentLanguage()));
}
void Click()
{
++count;
if (count % 2) SetLanguage(LNG_('E','N','U','S'));
else SetLanguage(LNG_('P','L','P','L'));
RefreshLabel();
}
typedef ButtonApp CLASSNAME;
ButtonApp()
{
count = 0;
button <<= THISBACK(Click);
button.SetLabel(t_("&I'm an Ultimate++ button!"));
Add(button.VCenterPos(20).HCenterPos(200));
Add(label.BottomPos(0, 20).HCenterPos(200));
label.SetAlign(ALIGN_CENTER);
Sizeable().Zoomable();
RefreshLabel();
}
};
GUI_APP_MAIN
{
ButtonApp().Run();
}
translation file:
#ifdef _MSC_VER
#pragma setlocale("C")
#endif
// main.cpp
T_("Number of button clicks %d, language %s")
plPL("Liczba klikniêæ %d, jêzyk %s")
T_("&I'm an Ultimate++ button!")
plPL("Przycisk Ultimate++")
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 11:54:54 CEST 2025
Total time taken to generate the page: 0.00892 seconds
|