Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
Zbych is currently offline  Zbych
Messages: 325
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++")
Re: How to change language "on the fly"? [message #26927 is a reply to message #26924] Wed, 09 June 2010 21:56 Go to previous message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
Ok. I see my mistake. Since widgets, labels, texts are translated in the constructor, there is no other way than to create a new function that will replace all those texts.

[Updated on: Wed, 09 June 2010 21:57]

Report message to a moderator

Previous Topic: Updated Russian translation.
Next Topic: Some corrections in Report package
Goto Forum:
  


Current Time: Fri Mar 29 11:21:25 CET 2024

Total time taken to generate the page: 0.01519 seconds