Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Productivity Tools Toolkit, problem with i18n
Hello
I try to use the add-on TPT (Productivity Tools Toolkit) with that i18n feature.
But it does not work, I can not find the problem.
Here's the code
/*
* TptAppli.java
*
* Created on 17 mai 2012, 14:48
*/
package com.vaadin;
import com.autogenerer.categorie.CustomTableCategorie;
import com.autogenerer.controle.CustomTableControle;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.ui.*;
import eu.livotov.tpt.TPTApplication;
import eu.livotov.tpt.gui.widgets.TPTMultiView;
import eu.livotov.tpt.i18n.TM;
/**
*
* @author Amallek
* @version
*/
public class TptAppli extends TPTApplication {
ThemeResource icone1 = new ThemeResource("../theme/controle-16.png");
ThemeResource iconAdmin = new ThemeResource("../theme/configuration-16.png");
ThemeResource iconAide = new ThemeResource("../theme/aide-16.png");
ThemeResource iconSousAdmin = new ThemeResource("../theme/parametres-16.png");
ThemeResource icon2 = new ThemeResource("../theme/gestionnaire-16.png");
boolean isManageUrls = true;
TPTMultiView controller = new TPTMultiView(isManageUrls);
@Override
public void applicationInit() {
setTheme("theme");
TM.getDictionary().setDefaultLanguage("en");
Window mainWindow = new Window(TM.get("app.titre"));
mainWindow.getContent().setHeight(null);
mainWindow.getContent().setWidth(null);
VerticalLayout vert = new VerticalLayout();
MenuBar menu = new MenuBar();
menu.setImmediate(true);
MenuBar.MenuItem tableauBord = menu.addItem(TM.get("fonction1"), icone1, null);
tableauBord.addItem(TM.get("sous.fonction1.1"), icon2, action1);
MenuBar.MenuItem admin = menu.addItem(TM.get("fonction2"), iconAdmin, null);
admin.addItem(TM.get("sous.fonction2.1"), iconSousAdmin, action1);
admin.addItem(TM.get("sous.fonction2.2"), iconSousAdmin, action2);
admin.addItem(TM.get("sous.fonction2.3"), iconSousAdmin, action3);
vert.addComponent(menu);
vert.addComponent(controller);
controller.addView("customTableControle", CustomTableControle.class);
controller.addView("customTableCategorie", CustomTableCategorie.class);
controller.setFailsafeViewName("customTableCategorie");
mainWindow.addComponent(vert);
setMainWindow(mainWindow);
}
private MenuBar.Command action1 = new MenuBar.Command() {
public void menuSelected(MenuBar.MenuItem selectedItem) {
controller.switchView("customTableControle");
}
};
private MenuBar.Command action2 = new MenuBar.Command() {
public void menuSelected(MenuBar.MenuItem selectedItem) {
controller.switchView("customTableCategorie");
}
};
private MenuBar.Command action3 = new MenuBar.Command() {
public void menuSelected(MenuBar.MenuItem selectedItem) {
controller.switchView("customTableCategorie/50");
}
};
@Override
public void firstApplicationStartup() {
}
}
and
string.properties [en]
app.titre= Title of application
fonction1=anglais
sous.fonction1.1=anglais
fonction2=anglais
sous.fonction2.1=anglais
sous.fonction2.2=anglais
sous.fonction2.3=anglais
label = this is a Label
odbc.btn.ok=OK
odbc.btn.cancel=Cancel
odbc.btn.yes=Yes
odbc.btn.no=No
idbc.btn.ok=OK
idbc.btn.cancel=Cancel
ddbc.btn.close=Close
string.properties [fr]
app.titre= Titre de l'application
label = c'est un Label
fonction1=français
sous.fonction1.1=français
fonction2=français
sous.fonction2.1=français
sous.fonction2.2=français
sous.fonction2.3=français
odbc.btn.ok=OK
odbc.btn.cancel=Annuler
odbc.btn.yes=OUI
odbc.btn.no=NON
idbc.btn.ok=OK
idbc.btn.cancel=Annuler
ddbc.btn.close=Fermer
here is the tree of my project
I do not see the concern, why it does not work.
language is alway in French
I use version 1.2 tpt and vaadin 6.7.5
thank you for your help
Thread is pretty old, but still posting it here because I faced the same problem with TPT 1.2.0 recently and didn't find any resolution unless I looked to TPT source code.
TM.getDictionary().setDefaultLanguage( "ru" ) doesn't work as described in TPT handbook. If you call TM.get ("someString") after that, it checks app locale first, see here. Simple grep shows that defaultLanguage is not used anywhere in the code.
Solutions:
- set application locale to the one you need: app.setLocale(new Locale ("en")).
- use overloaded method which allows to specify language explicitly: TM.getDictionary().get("ru", "RU", "someString")
TPT handbook is really confusing in this case...