fix localization

This commit is contained in:
Peter Hormanns 2017-06-22 17:27:54 +02:00
parent c812971073
commit 2299ec4a87
19 changed files with 65 additions and 50 deletions

View File

@ -33,14 +33,14 @@ public class CustomerPanel extends CustomComponent implements IHSPanel, Selected
tabsheet.setSizeFull();
tabsheet.addSelectedTabChangeListener(this);
tabsheet.addSelectedTabChangeListener(this);
tabsheet.addTab(new GenericForm("customer", session, itemId, "name"), I18N.getText("customer"));
tabsheet.addTab(new GenericForm("customer", session, itemId, "name"), I18N.getText("customer", getLocale()));
final HSTab usersTab = new HSTab("contact", session, "customer", itemId, "email");
usersTab.fillTable();
tabsheet.addTab(usersTab, I18N.getText("contact"));
tabsheet.addTab(usersTab, I18N.getText("contact", getLocale()));
HSTab aliasTab = new HSTab("mandat", session, "customer", itemId, "mandatRef");
tabsheet.addTab(aliasTab, I18N.getText("mandat"));
tabsheet.addTab(aliasTab, I18N.getText("mandat", getLocale()));
HSTab pacTab = new HSTab("pac", session, "customer", itemId, "name");
tabsheet.addTab(pacTab, I18N.getText("pac"));
tabsheet.addTab(pacTab, I18N.getText("pac", getLocale()));
return tabsheet;
}

View File

@ -27,14 +27,14 @@ public class DomainOptionsEditor extends CustomComponent implements IHSEditor {
public DomainOptionsEditor(final PropertyInfo propertyInfo, final HSAdminSession session, final Map<String, String> whereContext) {
this.checkboxes = new HashMap<>();
this.propertyInfo = propertyInfo;
this.setCaption(I18N.getText(propertyInfo.getName()));
this.setCaption(I18N.getText(propertyInfo.getName(), getLocale()));
layout = new VerticalLayout();
for (String opt : OPTIONS) {
final CheckBox checkBox = new CheckBox(I18N.getText("domainoption." + opt));
final CheckBox checkBox = new CheckBox(I18N.getText("domainoption." + opt, getLocale()));
checkboxes.put(opt, checkBox);
layout.addComponent(checkBox);
}
layout.setCaption(I18N.getText(propertyInfo.getName()));
layout.setCaption(I18N.getText(propertyInfo.getName(), getLocale()));
setCompositionRoot(layout);
}

View File

@ -30,10 +30,10 @@ public class DomainPanel extends CustomComponent implements IHSPanel, SelectedTa
public TabSheet createTabs(Object itemId) throws RpcException
{
final TabSheet tabsheet = new TabSheet();
tabsheet.addTab(new GenericForm("domain", session, itemId, "name"), I18N.getText("domain"));
tabsheet.addTab(new GenericForm("domain", session, itemId, "name"), I18N.getText("domain", getLocale()));
HSTab emailTab = new HSTab("emailaddress", session, "domain", itemId, "id");
emailTab.fillTable();
tabsheet.addTab(emailTab, I18N.getText("emailaddress"));
tabsheet.addTab(emailTab, I18N.getText("emailaddress", getLocale()));
return tabsheet;
}

View File

@ -44,12 +44,12 @@ public class EMailTargetEditor extends CustomComponent implements IHSEditor, Val
this.isEditAble = PanelToolbar.ACTION_EDIT.equals(action) || PanelToolbar.ACTION_NEW.equals(action);
this.propertyInfo = propertyInfo;
this.validators = new ArrayList<>();
this.setCaption(I18N.getText(propertyInfo.getName()));
this.setCaption(I18N.getText(propertyInfo.getName(), getLocale()));
this.aliases = targetsSelect("emailalias", session, whereContext);
this.postboxes = targetsSelect("user", session, whereContext);
postboxes.removeAll(aliases);
layout = new VerticalLayout();
layout.setCaption(I18N.getText(propertyInfo.getName()));
layout.setCaption(I18N.getText(propertyInfo.getName(), getLocale()));
setCompositionRoot(layout);
}
@ -175,7 +175,7 @@ public class EMailTargetEditor extends CustomComponent implements IHSEditor, Val
targetTypeSelect.setMultiSelect(false);
targetTypeSelect.setNullSelectionAllowed(true);
targetTypeSelect.setNullSelectionItemId(" ");
targetTypeSelect.addItems(new Object[] { " ", I18N.getText("emailtarget.email"), I18N.getText("emailtarget.postbox"), I18N.getText("emailtarget.alias") });
targetTypeSelect.addItems(new Object[] { " ", I18N.getText("emailtarget.email", getLocale()), I18N.getText("emailtarget.postbox", getLocale()), I18N.getText("emailtarget.alias", getLocale()) });
targetTypeSelect.setValue(" ");
targetTypeSelect.setWidth("6.0em");
addComponent(targetTypeSelect);
@ -184,7 +184,7 @@ public class EMailTargetEditor extends CustomComponent implements IHSEditor, Val
AbstractComponent targetField = null;
NativeSelect sel = null;
if (aliases.contains(target)) {
targetTypeSelect.setValue(I18N.getText("emailtarget.alias"));
targetTypeSelect.setValue(I18N.getText("emailtarget.alias", getLocale()));
sel = new NativeSelect();
sel.addItems(aliases);
sel.setValue(target);
@ -193,7 +193,7 @@ public class EMailTargetEditor extends CustomComponent implements IHSEditor, Val
targetField = sel;
} else {
if (postboxes.contains(target)) {
targetTypeSelect.setValue(I18N.getText("emailtarget.postbox"));
targetTypeSelect.setValue(I18N.getText("emailtarget.postbox", getLocale()));
sel = new NativeSelect();
sel.addItems(postboxes);
sel.setValue(target);
@ -201,7 +201,7 @@ public class EMailTargetEditor extends CustomComponent implements IHSEditor, Val
sel.setEnabled(isEditAble);
targetField = sel;
} else {
targetTypeSelect.setValue(I18N.getText("emailtarget.email"));
targetTypeSelect.setValue(I18N.getText("emailtarget.email", getLocale()));
targetField = new TextField();
targetField.setEnabled(isEditAble);
((TextField) targetField).setValue(target);
@ -229,16 +229,16 @@ public class EMailTargetEditor extends CustomComponent implements IHSEditor, Val
final String newValue = newValueObject.toString();
if (targetRow.getComponentCount() == 1) {
AbstractComponent comp = null;
if (I18N.getText("emailtarget.email").equals(newValue)) {
if (I18N.getText("emailtarget.email", getLocale()).equals(newValue)) {
final TextField textField = new TextField();
textField.addValueChangeListener(editor);
textField.setImmediate(true);
textField.setEnabled(isEditAble);
comp = textField;
} else {
if (I18N.getText("emailtarget.alias").equals(newValue) || I18N.getText("emailtarget.postbox").equals(newValue)) {
if (I18N.getText("emailtarget.alias", getLocale()).equals(newValue) || I18N.getText("emailtarget.postbox", getLocale()).equals(newValue)) {
final NativeSelect select = new NativeSelect();
if (I18N.getText("emailtarget.alias").equals(newValue)) {
if (I18N.getText("emailtarget.alias", getLocale()).equals(newValue)) {
select.addItems(aliases);
} else {
select.addItems(postboxes);

View File

@ -45,7 +45,7 @@ public class EntryPointsSelector extends CustomComponent implements ItemClickLis
final AbstractEntryPointsFactory entryPointsFactory = FactoryProducer.getEntryPointsFactory(mainWindow, "default");
int tabCount = 0;
for(String tabName : entryPointsFactory.getEntryPointNames(role)) {
accordion.addTab(new EntryPoint(this, tabName), I18N.getText(tabName));
accordion.addTab(new EntryPoint(this, tabName), I18N.getText(tabName, getLocale()));
tabCount++;
}
if (tabCount > 0) {

View File

@ -2,6 +2,7 @@ package de.hsadmin.web;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@ -24,7 +25,9 @@ public class GenericFormWindow extends Window implements IHSWindow {
public GenericFormWindow(final HSTab parent, final String module, final String action, final HSAdminSession session, final Map<String, String> whereContext)
{
super(I18N.getText(action) + " " + I18N.getText(module));
super();
final Locale locale = getLocale();
setCaption(I18N.getText(action, locale) + " " + I18N.getText(module, locale));
this.parent = parent;
center();
setModal(true);

View File

@ -85,7 +85,7 @@ public class HSConfirmBox extends HorizontalLayout {
}
}
});
cancelButton = new Button(I18N.getText("cancel"));
cancelButton = new Button(I18N.getText("cancel", getLocale()));
cancelButton.setClickShortcut(KeyCode.ESCAPE);
cancelButton.addClickListener(new ClickListener()
{

View File

@ -9,7 +9,8 @@ public class HSPasswordField extends PasswordField implements IHSEditor {
private static final long serialVersionUID = 1L;
public HSPasswordField(final String name, final boolean passwordRequired) {
super(I18N.getText(name));
super();
setCaption(I18N.getText(name, getLocale()));
addValidator(new PasswordValidator(passwordRequired));
}

View File

@ -16,7 +16,8 @@ public class HSSelect extends NativeSelect implements IHSEditor {
}
public HSSelect(final String label, final int defaultIndex, final List<String> values) {
super(I18N.getText(label));
super();
setCaption(I18N.getText(label, getLocale()));
this.propertyName = label;
super.addItems(values);
if (values != null && values.size() > defaultIndex) {

View File

@ -149,7 +149,7 @@ public class HSTab extends CustomComponent {
while (properties.hasNext()) {
final PropertyInfo propertyInfo = properties.next();
if (showColumnInTable(propertyInfo)) {
grid.addContainerProperty(I18N.getText(propertyInfo.getModule() + "." + propertyInfo.getName()), String.class, "");
grid.addContainerProperty(I18N.getText(propertyInfo.getModule() + "." + propertyInfo.getName(), getLocale()), String.class, "");
}
}
grid.setSelectable(true);

View File

@ -11,7 +11,8 @@ public class HSTextField extends TextField implements IHSEditor {
private final String propertyName;
public HSTextField(final String name) {
super(I18N.getText(name));
super();
setCaption(I18N.getText(name, getLocale()));
this.propertyName = name;
}

View File

@ -25,7 +25,7 @@ public class HelpWindow extends Window {
final VerticalLayout subContent = new VerticalLayout();
subContent.setMargin(true);
subContent.setSizeFull();
final String helpBaseURL = I18N.getText("help.baseurl");
final String helpBaseURL = I18N.getText("help.baseurl", getLocale());
final Component helpContent = new BrowserFrame("Help Window", new ExternalResource(helpBaseURL + helpTopic));
helpContent.setSizeFull();
subContent.addComponent(helpContent);

View File

@ -1,16 +1,21 @@
package de.hsadmin.web;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class I18N {
private static final ResourceBundle TEXTS = ResourceBundle.getBundle("de.hsadmin.web.main");
private static final ResourceBundle TEXTS_DE = ResourceBundle.getBundle("de.hsadmin.web.main", Locale.GERMAN);
private static final ResourceBundle TEXTS_EN = ResourceBundle.getBundle("de.hsadmin.web.main", Locale.ENGLISH);
public static String getText(final String textProperty) {
public static String getText(final String textProperty, final Locale loc) {
String textValue;
try{
textValue = I18N.TEXTS.getString(textProperty);
textValue = I18N.TEXTS_EN.getString(textProperty);
if (loc.getLanguage().equals(Locale.GERMAN.getLanguage())) {
textValue = I18N.TEXTS_DE.getString(textProperty);
}
}catch(MissingResourceException e){
textValue = "./. " + textProperty;
}

View File

@ -27,7 +27,8 @@ public class LoginWindow extends Window {
private static final long serialVersionUID = 1L;
public LoginWindow(final HSAdminUI parent, final TicketService ticketService) {
super(I18N.getText("login.title"));
super();
setCaption(I18N.getText("login.title", getLocale()));
center();
setModal(true);
setWidth("480px");
@ -35,11 +36,11 @@ public class LoginWindow extends Window {
final FormLayout subContent = new FormLayout();
subContent.setMargin(true);
final TextField login = new TextField(I18N.getText("user.name"));
final TextField login = new TextField(I18N.getText("user.name", getLocale()));
login.setWidth("100%");
subContent.addComponent(login);
login.focus();
final PasswordField password = new PasswordField(I18N.getText("password"));
final PasswordField password = new PasswordField(I18N.getText("password", getLocale()));
password.setWidth("100%");
subContent.addComponent(password);
final Label feedback = new Label("");
@ -48,7 +49,7 @@ public class LoginWindow extends Window {
subContent.addComponent(feedback);
feedback.setStyleName(ValoTheme.LABEL_FAILURE);
final Button okButton = new Button(I18N.getText("login.button"));
final Button okButton = new Button(I18N.getText("login.button", getLocale()));
okButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
okButton.setClickShortcut(KeyCode.ENTER);
okButton.addClickListener(new ClickListener()
@ -74,9 +75,9 @@ public class LoginWindow extends Window {
}
}
try {
final String user = credentials.get(I18N.getText("user.name"));
final String user = credentials.get(I18N.getText("user.name", getLocale()));
final String loginUser = user.length() == 3 ? "hsh00-" + user : user;
final String password = credentials.get(I18N.getText("password"));
final String password = credentials.get(I18N.getText("password", getLocale()));
final String grantingTicket = ticketService.getGrantingTicket(loginUser, password);
if (grantingTicket != null && !grantingTicket.isEmpty()) {
feedback.setValue("successful login");
@ -99,7 +100,7 @@ public class LoginWindow extends Window {
}
});
subContent.addComponent(okButton);
final Link linkToOld = new Link(I18N.getText("main.panel.link_to_old"), new ExternalResource("https://admin.hostsharing.net/hsarweb"));
final Link linkToOld = new Link(I18N.getText("main.panel.link_to_old", getLocale()), new ExternalResource("https://admin.hostsharing.net/hsarweb"));
subContent.addComponent(linkToOld);
setContent(subContent);

View File

@ -10,8 +10,8 @@ public class MainPanel extends CustomComponent{
private static final long serialVersionUID = -1085100738394404620L;
public MainPanel() {
final String helpBaseURL = I18N.getText("help.baseurl");
final Component helpContent = new BrowserFrame(I18N.getText("main.panel.title"), new ExternalResource(helpBaseURL + "hsadmin"));
final String helpBaseURL = I18N.getText("help.baseurl", getLocale());
final Component helpContent = new BrowserFrame(I18N.getText("main.panel.title", getLocale()), new ExternalResource(helpBaseURL + "hsadmin"));
helpContent.setSizeFull();
setCompositionRoot(helpContent);
setSizeFull();

View File

@ -52,7 +52,7 @@ public class MainToolbar extends CustomComponent implements ClickListener {
final Button btn = new Button();
btn.setId(name + "-btn");
btn.setIcon(new ThemeResource("../icons/" + icon + "-icon.png"));
btn.setDescription(I18N.getText(name + ".tooltip"));
btn.setDescription(I18N.getText(name + ".tooltip", getLocale()));
btn.setStyleName("borderless");
btn.addClickListener(this);
return btn;

View File

@ -31,23 +31,23 @@ public class PackagePanel extends CustomComponent implements IHSPanel, SelectedT
{
final TabSheet tabsheet = new TabSheet();
tabsheet.addSelectedTabChangeListener(this);
tabsheet.addTab(new GenericForm("pac", session, itemId, "name"), I18N.getText("pac"));
tabsheet.addTab(new GenericForm("pac", session, itemId, "name"), I18N.getText("pac", getLocale()));
final HSTab usersTab = new HSTab("user", session, "pac", itemId, "name");
usersTab.fillTable();
tabsheet.addTab(usersTab, I18N.getText("user"));
tabsheet.addTab(usersTab, I18N.getText("user", getLocale()));
final HSTab aliasTab = new HSTab("emailalias", session, "pac", itemId, "name");
tabsheet.addTab(aliasTab, I18N.getText("emailalias"));
tabsheet.addTab(aliasTab, I18N.getText("emailalias", getLocale()));
final HSTab domainTab = new HSTab("domain", session, "pac", itemId, "name");
tabsheet.addTab(domainTab, I18N.getText("domain"));
tabsheet.addTab(domainTab, I18N.getText("domain", getLocale()));
final HSTab mysqluserTab = new HSTab("mysqluser", session, "pac", itemId, "name");
tabsheet.addTab(mysqluserTab, I18N.getText("mysqluser"));
tabsheet.addTab(mysqluserTab, I18N.getText("mysqluser", getLocale()));
final HSTab mysqldbTab = new HSTab("mysqldb", session, "pac", itemId, "name");
tabsheet.addTab(mysqldbTab, I18N.getText("mysqldb"));
tabsheet.addTab(mysqldbTab, I18N.getText("mysqldb", getLocale()));
final HSTab postgresqluserTab = new HSTab("postgresqluser", session, "pac", itemId, "name");
tabsheet.addTab(postgresqluserTab, I18N.getText("postgresqluser"));
tabsheet.addTab(postgresqluserTab, I18N.getText("postgresqluser", getLocale()));
final HSTab postgresqldbTab = new HSTab("postgresqldb", session, "pac", itemId, "name");
tabsheet.addTab(postgresqldbTab, I18N.getText("postgresqldb"));
tabsheet.addTab(postgresqldbTab, I18N.getText("postgresqldb", getLocale()));
return tabsheet;
}

View File

@ -60,7 +60,7 @@ public class PanelToolbar extends HorizontalLayout implements ClickListener {
if (image != null) {
btn.setIcon(new ThemeResource("../icons/" + image + "-icon.png"));
}
btn.setDescription(I18N.getText(tooltip));
btn.setDescription(I18N.getText(tooltip, getLocale()));
btn.setStyleName("borderless");
btn.addClickListener(this);
return btn;
@ -88,7 +88,7 @@ public class PanelToolbar extends HorizontalLayout implements ClickListener {
final Object value = parent.getSelection();
if (value == null) {
if (ACTION_EDIT.equals(action) || ACTION_DELETE.equals(action)) {
UI.getCurrent().addWindow(new InfoWindow(I18N.getText("emptySelectionMessage") + " " + action));
UI.getCurrent().addWindow(new InfoWindow(I18N.getText("emptySelectionMessage", getLocale()) + " " + action));
return;
}
}

View File

@ -5,6 +5,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@ -28,7 +29,9 @@ public class UserProfileWindow extends Window implements IHSWindow {
public UserProfileWindow(final HSAdminSession session, final Map<String, String> whereContext)
{
super(I18N.getText("edit") + " " + I18N.getText("user"));
super();
final Locale locale = getLocale();
setCaption(I18N.getText("edit", locale) + " " + I18N.getText("user", locale));
center();
setModal(true);
setWidth("640px");