Project

General

Profile

Template translation updates only after browser refresh

Added by Winfried Dobbe almost 7 years ago

Hi,

I have a template widget with translated text in it (see below). It uses the ${tr:} function to translate text.

When I call

Wt::WApplication::instance()->setLocale(Wt::WLocale(newLocale));

the title WText widget is translated immediately, but the text that uses the ${tr:} function is not translated until I refresh my browser.

Is this expected behaviour? If so, is it possible to initiate a browser refresh from the server? WApplication::enableUpdates(true) + WApplication::triggerUpdate() doesn't work in this case.

thanks in advance for any help,

Winfried

template file:

<hr/>
${title}
<hr/><br/>

${tr:preferences-select-lang-label} ${lang-select}

<hr/>

Code to load template:

auto template_widget = std::make_unique<Wt::WTemplate>();
template_widget->addFunction("tr", &Wt::WTemplate::Functions::tr);
template_widget->setTemplateText(loadTemplate("choose_language.tpl"));
auto title = std::make_unique<Wt::WText>( Wt::WString::tr("language-title") );
template_widget->bindWidget("title", std::move(title));
auto langCombo = std::make_unique<Wt::WComboBox>();
template_widget->bindWidget("lang-select", std::move(langCombo));